Renaming and moving mounted partitions around

The need to do this came from a leap 42.2 install. My previous install mapped /home to a raid 1 array. I imported my partitioning but /home finished up at root on the system disk. As it turned out it was also time to change drives so may as well enlarge them as well. I had copied /home to /homeA using rsync -arX to preserve attributes and asked on here if it was just a case of renaming the dir’s and changing fstab. I’d also created 2 copies of fstab in case things went wrong. One called fstabssd, same as the current one, the other fstabraid which mounted /home on the raid array md0. I found I could change the name of /home to /homeold or whatever but not homeA to home. Just had error messages. Some one pointed out that it wasn’t possible to rename a mounted directory or one that was used by some process. I had wondered about killing mdadm prior to that. So used fuse to see what was using it.


/home/john # fuser -v /homeA
                     USER        PID ACCESS COMMAND
/homeA:              root     kernel mount /homeA

That cleared this aspect up. Fuse’s behaviour on opensuse doesn’t match some other distro’s. -v is needed as other options don’t seem to generate any output. It’s probably overwritten by the prompt. I had already seen that mdadm was a running process but it clearly wasn’t currently using it…Fuse can kill processes but that could be rather lethal so best kill some other way if needed. Killing mount wouldn’t be a good idea at all. So


# /umount homeA
# /mv  home homeOld
# /mv  homeA home
# /etc  cp --preserve=all fstabraid fstab
# /etc  mount /home

These preserve attributes. I did this from my user desktop in konsole as root. Out of curiosity I fire up a kde desktop application when /home was unmounted. It generated error messages. I suspect if I had logged out and back in as root it would have still worked. I didn’t use single user mode at the prompt because leap doesn’t offer any obvious way of getting there from the start up menu. Safe mode just goes to the desktop. After remounting the now new /home desktop app’s appeared to be ok.

As a check to see that it had done what I wanted.


# df /home/
# Filesystem     1K-blocks      Used Available Use% Mounted on
# /dev/md0       961301640 179848828 780459668  19% /home

I then tried to reboot from the desktop. Nothing happened so rebooted from the prompt. After that kde’s reboot worked and my desktop was back to exactly as it was when i used rysnc with firefox showing the same pages. I suppose I could have updated the copy before making the changes. I think rsync will do that. It looks useful. It has lots of options though which would mean I’d have to study all of them just in case. I have to work like this because I don’t know what commands to use so need the web or have to ask. I wouldn’t use the web as root.

There is another way of doing the same thing. A bootable ISO. I use Knoppix for that if needed, the dvd version. In that I could simply rename the home’s and change fstab. However I was concerned that it couldn’t assemble the raid only detect the disks. As an afterthought I realised that the presence of md0 only mattered when the main machine booted up so could have done it that way. It mounts all of the drives to /media. Even so I built the raid using mdadm --assemble scd1 etc and that worked but mounted it to Knoppix rather than /media. I find it useful to have around as it can be used for all sorts even recovering files if a re install etc is needed… Knoppix has always detected my hardware correctly so use that.

:)It isn’t a good idea to try a desktop app while /home isn’t mounted but as firefox was up before it seems to be ok. There were indications that dolphin didn’t exit cleanly but I did post the results of the changes some where else before the console reboot. I’d normally do this sort of thing while having my laptop connected to the web and no active apps on the desktop other than the konsole. Using firefox while home is not mounted may not work out. I suspect it needs to be already pointed where needed. Using it before and after the remount should be perfectly ok. It would be rather worrying if it wasn’t.

John