0

After moving var to a new partition by the following commands, How can I see the old var ?

mkdir /var2
mount /dev/sda5 /var2

Sync your current var:

rsync -a /var/ /var2

Add the entry to /etc/fstab

/dev/sda5    /var    ext4    defaults      2 2
mook765
  • 15,925
eugene
  • 183
  • 1
  • 5

2 Answers2

0

Moving the /var directory to a new separate disk or partition and keep access to the old /var directory.
To 'see' an old var directory after fstab modificaton : rename the old var directory.

# Boot with init 1 single user mode
sudo init 1

# Prepare new VAR directory
mkdir /mnt/newvar
mount /dev/sda5 /mnt/newvar
cp -ax /var/* /mnt/newvar

# Rename old VAR
mv /var /old_var
# Remount the disk partition to /var
mkdir /var
umount /dev/sda5
mount /dev/sda5 /var

# Alter fstab to apply changes
#--> /dev/sda5    /var    ext4    defaults    0    2

# Restart the multitask mode
init 5
cmak.fr
  • 8,696
0

If you have the new partition mounted on /var already, you can use a bind-mount:

sudo mount --bind / /mnt

This will mount your root-partition at /mnt without affecting the current mount-points, so when looking in /mnt, you will see the original directory contents.

Thus you will find the content of your "old" /var in /mnt/var now. If you want to remove the content of your "old" /var you can use

sudo rm -r /mnt/var/*

Unmount when your done with

sudo umount /mnt
mook765
  • 15,925