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.
I have made a Debian image that I need to upload to my server. The image was created on a local computer that is around 244GB.
Device Boot Start End Blocks Id System
/dev/sda 0 244198584
/dev/sda1 * 2048 175783297 87890625 83 Linux
/dev/sda2 175783934 185548799 4882433 5 Extended
/dev/sda5 175783936 185548799 4882432 82 Linux swap / Solaris
The image I need to upload to the VPS can only be 100GB or less. What I am trying to do is use dd to make a smaller copy of the disk. I am going to try to limit the dd to copying less than 100GB using this:
Not sure if the image will be of any use with a 512K byte size, if the file system has 4K blocks, that should be the maximum byte size.
You'll need to shrink the partitions so they add up to 100GB or less if you are to use a simple dd command. DD does not sift out used space leaving out unused space, whatever formula you drum up to get the size down to 100GB with DD will give you a useless image. As partition sizes won't match what the partition table reports, and you'll be missing a lot of stuff etc.
Other than that, if you want the restored image to replicate exact size of the original, you need to use a back up utility that only copies used space like Clonezilla or Image for Dos, these utilities will also compress the image making it 10GB or less. And the restored image will have same partition layout, same size.
NOTE: When there are only three partitions, there is no need for an extended and logical partition, just 2 primary partitions.
Not sure if the image will be of any use with a 512K byte size, if the file system has 4K blocks, that should be the maximum byte size.
You'll need to shrink the partitions so they add up to 100GB or less if you are to use a simple dd command. DD does not sift out used space leaving out unused space, whatever formula you drum up to get the size down to 100GB with DD will give you a useless image. As partition sizes won't match what the partition table reports, and you'll be missing a lot of stuff etc.
Other than that, if you want the restored image to replicate exact size of the original, you need to use a back up utility that only copies used space like Clonezilla or Image for Dos, these utilities will also compress the image making it 10GB or less. And the restored image will have same partition layout, same size.
NOTE: When there are only three partitions, there is no need for an extended and logical partition, just 2 primary partitions.
The extended was crated automatically. I did add the swap. So I need to change the 512K to 4K. I am using an Atom controller to create this. I want to shrink the disk to 100GB and then do a simple dd if/of, but I can't figure out how to shrink it with the various Linux tools. The debian is netinit only, so I am not sure that I could use Clonezilla. Any further information on how to shrink the 244GB disk down to 100GB would be appreciated. I am assuming that dd would handle the image creation correctly then. Thanks.
The extended was crated automatically. I did add the swap. So I need to change the 512K to 4K. I am using an Atom controller to create this. I want to shrink the disk to 100GB and then do a simple dd if/of, but I can't figure out how to shrink it with the various Linux tools. The debian is netinit only, so I am not sure that I could use Clonezilla. Any further information on how to shrink the 244GB disk down to 100GB would be appreciated. I am assuming that dd would handle the image creation correctly then. Thanks.
Get Gparted live, burn it to optical disk or USB key and boot it up, hit enter to select defaults at the questions. In the top rectangular window showing the partitions, highlight the swap and extended partitions and delete them from menus, from the edit menu, click "apply changes", you may need to do one at a time. Then highlight the root partition, select "resize" in menus, grab the right side of the root partition and slide it to the left to bring it down to desired size, something like 80GB, then highlight the free space and select "create" to create a 15-20GB primary swap partition in the free space, ensure to select format swap, then click "apply changes" and wait till complete before exiting Gparted.
Then you will need to boot into Debian, it should hang for a couple minutes because it can't mount swap but will eventually get to the desktop where you need to edit /etc/fstab file to change the UUID of the swap partition. Run command: sudo blkid /dev/sda2 to find the new UUID and replace the existing UUID for the swap partition in /etc/fstab file as sudo or root and save it. It should then boot normally.
Then you will need to add proper "count=" value in the DD command to only copy the two partitions and not the leftover free space.
dd uses the bs as a logical blocksize - it is irrelevant what the natural blocksize of the device (or filesystem for that matter) is. I typically use 4M for no better reason than I always have ...
Makes the math easier too.
dd uses the bs as a logical blocksize - it is irrelevant what the natural blocksize of the device (or filesystem for that matter) is. I typically use 4M for no better reason than I always have ...
Makes the math easier too.
Good to know, I'm accustomed to no larger than block size by habit from a forensics background.
Your choice, but it simply reduces the amount of I/O's issued by dd. Seems faster, but may be just imagination.
You must include all of the source disk that has any part of a partition in the image. So if you make it total 95G, maybe copy 99G to ensure you get it all - doesn't matter if you copy more, it is merely a "safety factor". The 99G is arbitrary to make sure it is under your 100G limit.
Unfortunately, gparted is not working past the initial start window on the controller. The loading of the gparted system reverts to a partitioning program at the first, so I'll reload and use it. Actually, I think I am ready to go now with the way it is.
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 175783297 87890625 83 Linux
/dev/sda2 175783934 185548799 4882433 5 Extended
/dev/sda5 175783936 185548799 4882432 82 Linux swap / Solaris
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.