I have a separate partition for my /home directory that I need to convert from xfs to ext4. I would like to be able to do this without having to reformat the disks on my machine. I have never done this before so I’m trying to determine the best plan of action.
I’ve found various ways online to mess around with partitions using the Yast ‘expert partitioner’ (opensuse specific - this seems like it’s useful for installing openSUSE), gparted, and a plethora of linux tools. I’m not sure what the pros/cons are of these or what my steps should be. From my short research into this problem, converting my /home partition will probably look like the following:
Resize the xfs /home partition to make room for a new one
Create an empty ext4 partition
Move/copy contents of xfs /home to some temporary location (where?)
Mount/unmount the xfs and ext4 partitions and adjust the /etc/fstab file accordingly
Copy data from temp location to new /home directory
I do not quite understand what you mean with " without having to reformat the disks". The word formatting is often (by MS Windows oriented people) used for creating a file system (on a container like a partition). But when you want to use a new ext4 file system, you have to create (format) it, else there is nothing.
Formatting is in fact the writing of tracks/blocks on a virgin disk. This is normally done by the manufacturer. Those people that call file system creation “formatting”, often call this “low level formatting” to have a difference. I doubt you mean this type of formatting.
And about your numbered list, IMHO this shows a bit of two ways to go.
I would say that you should have a piece of mass storage large enough to copy all of /home to. (In fact you should already have such a thing, because you make backups. Or not???)
All what follows is to be done from the console, nobody loged in in the GUI. Log in in the console with root. The idea is that no normal user is active and thus /home is not in use at all. The steps are then:
copy all in /home to another device;
and remove the entry from /etc/fstab;
use YaST > System > Partitioner (using
will give you the ncurses interface) create a ext4 file system on the partion (YaST also uses the word “formatting”, sorry) AND BE SURE YOU DO IT ON THE CORRECT PARTITION. In the same screens filling in that it should be mounted on /home and that it should be mounted now and on boot. YaST will then create the new entry in /etc/fstab for you;
copy all back to /home;
For the copy, you can use e.g. tar, but also cp has enough possibilities. Take care you use options that preserve ownership/permissions of the copied files. Want more advice? Please ask.
Sorry for the ambiguous word choice - by ‘without having the reformat the disks’ I meant reinstall Tumbleweed and reformat the partitions as new, (i.e delete all data and do a fresh install). If I could shuffle my data around by using backups to achieve the same result that would save a bunch of time.
By ‘correct partition’ do you mean the current partition UUID or the associated /dev/sd*? I’m assuming the UUID gets replaced…
Also, should all the copying of data back to /home after remounting the new drive also be done as root or as my user? As far as my system is concerned, am I correct in thinking everything about my user remains the same (i.e UID, group permissions)?
I’d recommend what you described here but can be modified optionally as follows… If you can excuse my not describing in detail the overall steps as you’ve described…
When you say “create an empty ext4 partition” you should understand that is actually at least two separate steps…
Create a partition (there is no such thing as an ext4 partition)
Format the space within your new partition as EXT4
The mount/unmounting can be done by YaST partitioner.
In fact, it seems to me that you should be able to do everything you describe except copying data in the YaST module “Partitioner” in which case when you mount/unmount you simply point your /home to your new partition.
Although probably not necessary in your case because you’re not making changes to your root partition, my personal preference is to use Gparted Live to do my partitioning and formatting actions, then copy the data (don’t move so you always have the old partition to fall back if you make a mistake), then use the YaST Partitioner to re-point /home.
No matter how it’s done,
After you’ve successfully pointed /home to your EXT4 partition, you can remove the old XFS partition and expand your EXT4 partition if you wish (or leave as is for any possible future operations).
The UUID is that of the file system, NOT of the partition (well associated because the file system is on that partition)! So use /dev/sdXN, (but the correct one, else you might destroy another file system).
When using YaST to create the ext4 and organise the mounting, you can specify there that you want it again mounted by UUID (I assume that will be the default), but it will be another UUID because it is another file system.
Of course all this all is only done as root. Your user(s) has/have no saying or any task in this.
The UIS/GID and permissions should be kept as they are when you use the correct way to copy.
I hope you understand where my scenario differs from yours.
You first want to shrink your xfs and create the ext2 alongside it. Then, nevertheless that you have then source and destination available, you copy the contents to a third place, just to copy it then to the ext4.
So when you have a third place, why not my scenario. First copy to the third place. Then replace the xfs in situ with the ext4 and then copy back. No need for shrinking (always tricky IMHO) and after that possibly enlarging (at the front side?) of the new one.
BTW whenever you are asking about things like partitioning, always add at least an
to your post. Then people are much more sure about what they are talking. I has to make several assumptions now. I hope they were correct.
Another hint. When you want to be very sure there is no GUI login from anybody during the action, boot in run level 3 (or change to run level 3 from the console).