Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Is there an easy way to copy a filesystem in Linux? I currently have one ext2 filesystem with / on it. I want Linux on a different hdd. Can I copy the whole partition to the new disk? how?
Also, is it possible to resize an ext2 partition? Even if only to make it smaller, I would value this alot.
Thank you. To shrink the fs, you would need to run resize2fs first then parted shrink, correct? To grow you would need to run them in the opposite order, correct?
Will that copy command keep special files such as /dev/* intact? Also, will it keep ownership and permissions intact?
What is the cpio command and how does it differ from cp ?
My last post was a bit misleading, you are correct, resize before shrinking with parted.
From the resize2fs man page:
Quote:
If you wish to shrink the an ext2 partition, first use
resize2fs to shrink the size of filesystem. Then you may
use fdisk(8) to shrink the size of the partition. When
shrinking the size of the partition, make sure you do not
make it smaller than the new size of the ext2 filesystem!
The cpio program is for creating and extracting from archives. It will preserve ownership, permissions and dates.
Thank you very much! I cannot wait to try this out!
This is one of many steps I am learning to do in order to make my linux box do as I wish. By the time I'm done with it, perhaps I'll know how to use linux a little hahahaha. Thanks!!
I realize this thread is really old but it's come close enough to answering a question I have.
Is there's actually an advantage to creating a new partition and then using find-cpio instead of just using parted to copy it? ...or is it strictly a preference because parted is unfriendly and maybe even a little scary? How many ways are there of creating a copy of a partition?
Quote:
Originally posted by crabboy
GNU parted will also copy partitions, but I'd prefer to mount the new partition and issue a command such as:
Code:
find / -xdev | cpio -pvmd /mnt
This will copy everything recursivly from / to the /mnt mount point.
The reason cpio is preferred to parted has nothing to do with parted being scary or hard to use. I believe that when you copy a partition with parted, the copy will neccesarily be the same size as the original. If you are copying a small partition to a big drive and you want to use more space for the copy of the partition, you'd have to copy it, then resize it. This is tedious. cpio is preferred because it will just copy the files to a ready made partition that can be any size you wish so long as it is big enough to hold the data.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.