Skip to content

Instantly share code, notes, and snippets.

@scottstanfield
Created November 23, 2021 17:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottstanfield/cb8bbe2f4591202372c60a560d32ba2b to your computer and use it in GitHub Desktop.
Save scottstanfield/cb8bbe2f4591202372c60a560d32ba2b to your computer and use it in GitHub Desktop.
Boot from Grub and add new drive for /var partition

Grub boot linux manually (hold shift or ESC)

set pager=1
cat /boot/grub/grub.cfg

set root=(hd0,gpt2)
linux /boot/vmlinuz-5.4.0-45-generic root=UUID=0ad8dbaf-6d97-4836-8fa5-612c7e5021c6 ro recovery nomodeset
initrd /boot/initrd.img-5.4.0-45-generic
boot

Safe boot to console now

https://linuxconfig.org/how-to-move-var-directory-to-another-partition

attach new HD to SATA port and boot

sudo su    # run all as root or prepend with sudo
lsblk		  # look for new drive like /dev/sdb

fdisk /dev/sdb		# create *partition*: n p 

    p 		print partition
    d		delete
    n		new (p, enter, enter)
    w		write
    
    <enter> w

mkfs.ext4 /dev/sdb1        # format first partition

mkdir /mnt/home
mount /dev/sdb2 /mnt/home

sudo mkdir /mnt/newdrive
sudo mount /dev/sdb2 /mnt/newdrive

# now move var
sudo du -hs /var
sudo rsync -aqxP /var/* /mnt/newdrive

# Add new line to bottom of /etc/fstab
nano /etc/fstab
/dev/sdb1 /var ext4 defaults 0 2

sudo mount -a

# now /var is remapped but old var is full

# final step is clean boot off USB Linux, map old drive 
# and rm -rf /var
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment