LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-20-2017, 06:15 PM   #1
ppmoore
LQ Newbie
 
Registered: Sep 2006
Posts: 25

Rep: Reputation: 0
How to reduce linux disk size before virtualizing it?


Hello,

I have Ubuntu installed on an SSD in my laptop. I've decided I want to install Windows instead of Linux, and to run Linux as a VM guest on Windows using Virtualbox. The SSD is 256GB, of which only about 60GB in total is used by the various partitions on the disk. The rest of the space is simply unallocated.

I was thinking of using dd to convert the installation to an image file, and then convert the image file to a VDI file using the virtualbox management tools.

Code:
dd if=/dev/sdb of=/VMs/sdb.img
The problem is that dd takes complete copy of the disk, including the unused space; in my case the image file will have the same 256GB size as the original SSD. I would like to reduce the size of this image file. Is there a way to do this using dd (or any other tool)?. I've noticed dd's count option. Can this be used?

I've googled this, and the emphasis seems to be on intermediate file size for file transportation purposes, which can be reduced by piping dd's output through gzip. But this won't affect the actual image file size.

Many thanks,
Paul
 
Old 03-20-2017, 06:59 PM   #2
jefro
Moderator
 
Registered: Mar 2008
Posts: 15,896

Rep: Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313Reputation: 2313
I might be tempted to use gparted to shrink the partitons from a live media. Then two ways to go.

1. Copy it over to some place. The now smaller partition and boot area.

Then you could dd then maybe convert it or import it to a vm.

Or

2. Use some clone app like clonezilla/gparted/partimage or such to move the install off.

Then load windows, update (forever) and install a vm.


Note, in the clone process you'd only need the sdx part of the partition and boot info and not the entire drive like you were trying to do. Just the file based would be what clonezilla does but doesn't like going smaller.



Note, in reality you could possibly zero out free space and dd with compression to some file then maybe use that on a growing vm drive. I've never done it that way.

Last edited by jefro; 03-20-2017 at 07:03 PM.
 
Old 03-20-2017, 07:10 PM   #3
Ztcoracat
LQ Guru
 
Registered: Dec 2011
Distribution: Slackware
Posts: 7,116
Blog Entries: 9

Rep: Reputation: Disabled
http://gparted.org/livecd.php
 
Old 03-20-2017, 08:03 PM   #4
michaelk
Moderator
 
Registered: Aug 2002
Posts: 15,402

Rep: Reputation: 1655Reputation: 1655Reputation: 1655Reputation: 1655Reputation: 1655Reputation: 1655Reputation: 1655Reputation: 1655Reputation: 1655Reputation: 1655Reputation: 1655
You could create a smaller drive image file and copy using loop devices(s) like in the link below.

https://wiki.archlinux.org/index.php...irtual_machine
 
Old 03-21-2017, 01:09 AM   #5
ppmoore
LQ Newbie
 
Registered: Sep 2006
Posts: 25

Original Poster
Rep: Reputation: 0
Thanks for the replies.

I don't need to use gparted to reduce the size of the partitions. The problem isn't the size of the partitions on the disk - as I indicated, they only take up about 60GB. The problem is the physical size of the SSD. The SSD is 256GB, and I'm trying to reduce the size of the image file generated by the output of dd, from256GB to something like 80GB.

@michaelk: I think that using a loop device is a solution. I'll try it later this evening.

Paul
 
Old 03-21-2017, 01:21 AM   #6
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 1,152

Rep: Reputation: 192Reputation: 192
Post

Quote:
Originally Posted by ppmoore View Post
Thanks for the replies.

I don't need to use gparted to reduce the size of the partitions. The problem isn't the size of the partitions on the disk - as I indicated, they only take up about 60GB. The problem is the physical size of the SSD. The SSD is 256GB, and I'm trying to reduce the size of the image file generated by the output of dd, from256GB to something like 80GB.

@michaelk: I think that using a loop device is a solution. I'll try it later this evening.

Paul
If dd produces 80GB, I think it should be okay already. How do you know that it's only using 60GB?

Or check out this one: https://superuser.com/questions/6108...reated-with-dd

Command from above link: losetup --find --partscan foo.img

Last edited by JJJCR; 03-21-2017 at 01:30 AM. Reason: edit
 
  


Reply

Tags
dd, disk, virtualization


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
/opt size reduce process in redhat linux 4 sumitdhar Linux - Newbie 3 07-23-2012 11:19 AM
Reduce virtual image size of Linux guest in VirtualBox chris1606 Linux - Server 3 04-14-2009 06:51 AM
Configuring and compiling kernel to reduce the size of linux near to 54 MB RohitChawla Fedora 3 12-10-2004 07:46 AM
Knoppix Hdd installation -I want to reduce the size on Disk!! rayesteq Linux - General 2 09-13-2004 05:02 AM


All times are GMT -5. The time now is 04:24 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration