vmware虛擬機器調整ubuntu10.04分割槽大小

commshare發表於2011-05-04

vmware20G分割槽大小已經接近用完了。

開機一直提示容量小,

容量擴充,vmware有圖形介面的選項。在hard disk哪裡調整。

 

25G了

 

 

調整之後,新增加了5G的容量,可以用ubuntu自帶的disk utility來格式化和掛載。

但是新分割槽,預設是掛在到/media下的,開機還是會提示容量小。/分割槽的並沒有被擴大。

因此需要有其他的辦法來解決。

=============================================================

參考了一篇使用lvm分割槽的文章。

感覺有點複雜,有專門的一篇英文文章講這個過程。

 

 

zhangbin@ubuntu:~$ sudo su

[sudo] password for zhangbin: 

froot@ubuntu:/home/zhangbin# fdisk -l

 

Disk /dev/sda: 26.8 GB, 26843545600 bytes   磁碟空間擴大了

255 heads, 63 sectors/track, 3263 cylinders   255頭    63個扇區 每 磁軌   3263個圓柱體

Units = cylinders of 16065 * 512 = 8225280 bytes       單元

Sector size (logical/physical): 512 bytes / 512 bytes   扇區大小(邏輯/物理)  都是512位元組。

I/O size (minimum/optimal): 512 bytes / 512 bytes   I/O 大小(最小/最大) 都是512位元組。

Disk identifier: 0x00030124   裝置識別碼

 

 

啟動裝置加*           起始         結束      塊           id     系統

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2497    20051968   83  Linux

/dev/sda2            2497        2611      916481    5  Extended   有一個擴充套件分割槽

/dev/sda3            2612        3263     5237190   83  Linux

/dev/sda5            2497        2611      916480   82  Linux swap / Solaris

root@ubuntu:/home/zhangbin# fdisk

 

Usage:

 fdisk [options] <disk>    change partition table

 fdisk [options] -l <disk> list partition table(s)

 fdisk -s <partition>      give partition size(s) in blocks

 

Options:

 -b <size>                 sector size (512, 1024, 2048 or 4096)

 -c                        switch off DOS-compatible mode

 -h                        print help

 -u <size>                 give sizes in sectors instead of cylinders

 -v                        print version

 -C <number>               specify the number of cylinders

 -H <number>               specify the number of heads

 -S <number>               specify the number of sectors per track

root@ubuntu:/home/zhangbin# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1             19737268  17850536    884136  96% /

none                    250352       256    250096   1% /dev

none                    254580       168    254412   1% /dev/shm

none                    254580       112    254468   1% /var/run

none                    254580         0    254580   0% /var/lock

none                    254580         0    254580   0% /lib/init/rw

/dev/sda3              5154884    141304   4751724   3% /media/ExpandP

 

 

root@ubuntu:/home/zhangbin# df -l

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1             19737268  17850536    884136  96% /

none                    250352       256    250096   1% /dev

none                    254580       168    254412   1% /dev/shm

none                    254580       112    254468   1% /var/run

none                    254580         0    254580   0% /var/lock

none                    254580         0    254580   0% /lib/init/rw

/dev/sda3              5154884    141304   4751724   3% /media/ExpandP   新分的那個區,我起名叫做ExpandP

 

 

root@ubuntu:/home/zhangbin# mount /dev/sda4 /

mount: special device /dev/sda4 does not exist

root@ubuntu:/home/zhangbin# mount /dev/sda3 / 掛到/上。

root@ubuntu:/home/zhangbin# df -l

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1             19737268  17850536    884136  96% /

none                    250352       256    250096   1% /dev

none                    254580       168    254412   1% /dev/shm

none                    254580       112    254468   1% /var/run

none                    254580         0    254580   0% /var/lock

none                    254580         0    254580   0% /lib/init/rw

/dev/sda3              5154884    141304   4751724   3% /media/ExpandP

/dev/sda3             19737268  17850536    884136  96% /

 

root@ubuntu:/home/zhangbin# df -l

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1             19737268  17850536    884136  96% /

none                    250352       256    250096   1% /dev

none                    254580       168    254412   1% /dev/shm

none                    254580       112    254468   1% /var/run

none                    254580         0    254580   0% /var/lock

none                    254580         0    254580   0% /lib/init/rw

/dev/sda3             19737268  17850536    884136  96% /

root@ubuntu:/home/zhangbin# mount /dev/sda3 /

mount: /dev/sda3 already mounted or / busy

mount: according to mtab, /dev/sda1 is already mounted on /  mtab是個mount表吧。

 

 

 

root@ubuntu:/# umount /dev/sda3  從/上解除安裝sda3

umount: /: device is busy.   這個是什麼歌意思呢?

        (In some cases useful info about processes that use

         the device is found by lsof(8) or fuser(1))

 

 

 

root@ubuntu:/home/zhangbin# apt-get install lvm   名字叫做lvm2了

Reading package lists... Done

Building dependency tree       

Reading state information... Done

E: Couldn't find package lvm

 

root@ubuntu:/home/zhangbin# pvcreate

The program 'pvcreate' is currently not installed.  You can install it by typing:

apt-get install lvm2

root@ubuntu:/home/zhangbin# apt-get install lvm2

 

 

root@ubuntu:/home/zhangbin# apt-get install lvm2

Reading package lists... Done

Building dependency tree       

Reading state information... Done

The following extra packages will be installed:

  libdevmapper-event1.02.1 watershed

The following NEW packages will be installed:

  libdevmapper-event1.02.1 lvm2 watershed

0 upgraded, 3 newly installed, 0 to remove and 221 not upgraded.

Need to get 447kB of archives.

After this operation, 1,282kB of additional disk space will be used.

Do you want to continue [Y/n]? y

Get:1 http://Ubuntu.cn99.com/ubuntu/ lucid-security/main libdevmapper-event1.02.1 2:1.02.39-1ubuntu4.1 [27.5kB]

Get:2 http://Ubuntu.cn99.com/ubuntu/ lucid/main watershed 5 [10.7kB]           

Get:3 http://Ubuntu.cn99.com/ubuntu/ lucid-security/main lvm2 2.02.54-1ubuntu4.1 [409kB]

Fetched 447kB in 60s (7,413B/s)                                                

Selecting previously deselected package libdevmapper-event1.02.1.

(Reading database ... 151964 files and directories currently installed.)

Unpacking libdevmapper-event1.02.1 (from .../libdevmapper-event1.02.1_2%3a1.02.39-1ubuntu4.1_i386.deb) ...

Selecting previously deselected package watershed.

Unpacking watershed (from .../archives/watershed_5_i386.deb) ...

Selecting previously deselected package lvm2.

Unpacking lvm2 (from .../lvm2_2.02.54-1ubuntu4.1_i386.deb) ...

Processing triggers for man-db ...

Setting up libdevmapper-event1.02.1 (2:1.02.39-1ubuntu4.1) ...

 

Setting up watershed (5) ...

update-initramfs: deferring update (trigger activated)

 

Setting up lvm2 (2.02.54-1ubuntu4.1) ...

update-initramfs: deferring update (trigger activated)

 

Processing triggers for libc-bin ...

ldconfig deferred processing now taking place

/sbin/ldconfig.real: /usr/lib/libavfilter.so.1 is not a symbolic link

 

/sbin/ldconfig.real: /usr/lib/libavutil.so.50 is not a symbolic link

 

/sbin/ldconfig.real: /usr/lib/libavdevice.so.52 is not a symbolic link

 

/sbin/ldconfig.real: /usr/lib/libavcore.so.0 is not a symbolic link

 

Processing triggers for initramfs-tools ...

update-initramfs: Generating /boot/initrd.img-2.6.32-26-generic

root@ubuntu:/home/zhangbin# 

 

 

分割槽

 

 

 

 

 

 

root@ubuntu:/home/zhangbin# parted

GNU Parted 2.2

Using /dev/sda

Welcome to GNU Parted! Type 'help' to view a list of commands.

(parted) print                                                            

Model: VMware, VMware Virtual S (scsi)

Disk /dev/sda: 26.8GB

Sector size (logical/physical): 512B/512B

Partition Table: msdos

 

Number  Start   End     Size    Type      File system     Flags

 1      1049kB  20.5GB  20.5GB  primary   ext4            boot

 2      20.5GB  21.5GB  938MB   extended

 5      20.5GB  21.5GB  938MB   logical   linux-swap(v1)

 3      21.5GB  26.8GB  5363MB  primary   ext4

 

 

 

 

(parted) df                                                               

  align-check TYPE N                        check partition N for TYPE(min|opt)

        alignment

  check NUMBER                             do a simple check on the file system

  cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER   copy file system to another partition

  help [COMMAND]                           print general help, or help on

        COMMAND

  mklabel,mktable LABEL-TYPE               create a new disklabel (partition

        table)

  mkfs NUMBER FS-TYPE                      make a FS-TYPE file system on

        partition NUMBER

  mkpart PART-TYPE [FS-TYPE] START END     make a partition

  mkpartfs PART-TYPE FS-TYPE START END     make a partition with a file system

  move NUMBER START END                    move partition NUMBER

  name NUMBER NAME                         name partition NUMBER as NAME

  print [devices|free|list,all|NUMBER]     display the partition table,

        available devices, free space, all found partitions, or a particular

        partition

  quit                                     exit program

  rescue START END                         rescue a lost partition near START

        and END

  resize NUMBER START END                  resize partition NUMBER and its file

        system

  rm NUMBER                                delete partition NUMBER

  select DEVICE                            choose the device to edit

  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER

  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition

        NUMBER

  unit UNIT                                set the default unit to UNIT

  version                                  display the version number and

        copyright information of GNU Parted

(parted) df -l                                                            

  align-check TYPE N                        check partition N for TYPE(min|opt)

        alignment

  check NUMBER                             do a simple check on the file system

  cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER   copy file system to another partition

  help [COMMAND]                           print general help, or help on

        COMMAND

  mklabel,mktable LABEL-TYPE               create a new disklabel (partition

        table)

  mkfs NUMBER FS-TYPE                      make a FS-TYPE file system on

        partition NUMBER

  mkpart PART-TYPE [FS-TYPE] START END     make a partition

  mkpartfs PART-TYPE FS-TYPE START END     make a partition with a file system

  move NUMBER START END                    move partition NUMBER

  name NUMBER NAME                         name partition NUMBER as NAME

  print [devices|free|list,all|NUMBER]     display the partition table,

        available devices, free space, all found partitions, or a particular

        partition

  quit                                     exit program

  rescue START END                         rescue a lost partition near START

        and END

  resize NUMBER START END                  resize partition NUMBER and its file

        system

  rm NUMBER                                delete partition NUMBER

  select DEVICE                            choose the device to edit

  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER

  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition

        NUMBER

  unit UNIT                                set the default unit to UNIT

  version                                  display the version number and

        copyright information of GNU Parted

  align-check TYPE N                        check partition N for TYPE(min|opt)

        alignment

  check NUMBER                             do a simple check on the file system

  cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER   copy file system to another partition

  help [COMMAND]                           print general help, or help on

        COMMAND

  mklabel,mktable LABEL-TYPE               create a new disklabel (partition

        table)

  mkfs NUMBER FS-TYPE                      make a FS-TYPE file system on

        partition NUMBER

  mkpart PART-TYPE [FS-TYPE] START END     make a partition

  mkpartfs PART-TYPE FS-TYPE START END     make a partition with a file system

  move NUMBER START END                    move partition NUMBER

  name NUMBER NAME                         name partition NUMBER as NAME

  print [devices|free|list,all|NUMBER]     display the partition table,

        available devices, free space, all found partitions, or a particular

        partition

  quit                                     exit program

  rescue START END                         rescue a lost partition near START

        and END

  resize NUMBER START END                  resize partition NUMBER and its file

        system

  rm NUMBER                                delete partition NUMBER

  select DEVICE                            choose the device to edit

  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER

  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition

        NUMBER

  unit UNIT                                set the default unit to UNIT

  version                                  display the version number and

        copyright information of GNU Parted

(parted) quit

root@ubuntu:/home/zhangbin# df -l

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1             19737268  17853368    881304  96% /

none                    250352       256    250096   1% /dev

none                    254580       168    254412   1% /dev/shm

none                    254580       112    254468   1% /var/run

none                    254580         0    254580   0% /var/lock

none                    254580         0    254580   0% /lib/init/rw

/dev/sda3              5154884    141304   4751724   3% /media/ExpandP

root@ubuntu:/home/zhangbin# umount /media/ExpandP

root@ubuntu:/home/zhangbin# df -l

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1             19737268  17853392    881280  96% /

none                    250352       256    250096   1% /dev

none                    254580       168    254412   1% /dev/shm

none                    254580       112    254468   1% /var/run

none                    254580         0    254580   0% /var/lock

none                    254580         0    254580   0% /lib/init/rw

root@ubuntu:/home/zhangbin# 

 

 

root@ubuntu:/home/zhangbin# pvs --help

  pvs: Display information about physical volumes  顯示物理卷得資訊

 

pvs

[-a|--all]

[--aligned]

[-d|--debug]

[-h|-?|--help] 

[--ignorelockingfailure]

[--nameprefixes]

[--noheadings]

[--nosuffix]

[-o|--options [+]Field[,Field]]

[-O|--sort [+|-]key1[,[+|-]key2[,...]]]

[-P|--partial] 

[--rows]

[--segments]

[--separator Separator]

[--trustcache]

[--unbuffered]

[--units hHbBsSkKmMgGtTpPeE]

[--unquoted]

[-v|--verbose]

[--version]

[PhysicalVolume [PhysicalVolume...]]

 

root@ubuntu:/home/zhangbin# pvs --a

pvs: option '--a' is ambiguous

  Error during parsing of command line.

root@ubuntu:/home/zhangbin# pvs -a

  PV         VG   Fmt Attr PSize PFree

  /dev/ram0           --      0     0 

  /dev/ram1           --      0     0 

  /dev/ram10          --      0     0 

  /dev/ram11          --      0     0 

  /dev/ram12          --      0     0 

  /dev/ram13          --      0     0 

  /dev/ram14          --      0     0 

  /dev/ram15          --      0     0 

  /dev/ram2           --      0     0 

  /dev/ram3           --      0     0 

  /dev/ram4           --      0     0 

  /dev/ram5           --      0     0 

  /dev/ram6           --      0     0 

  /dev/ram7           --      0     0 

  /dev/ram8           --      0     0 

  /dev/ram9           --      0     0 

  /dev/root           --      0     0 

  /dev/sda3           --      0     0 

  /dev/sda5           --      0     0 

root@ubuntu:/home/zhangbin# 

 

lvm> vgdisplay VolGroup00

  Volume group "VolGroup00" not found   沒有這個組。

lvm> pvs

lvm> pvcreate /dev/sda3

  Physical volume "/dev/sda3" successfully created     

lvm> pvs

  PV         VG   Fmt  Attr PSize PFree

  /dev/sda3       lvm2 --   4.99g 4.99g

lvm> 

lvm> vgextend VolGroup00 /dev/sda3

  Volume group "VolGroup00" not found

lvm> vgextend VolGroup00 /dev/sda1

  Volume group "VolGroup00" not found

lvm> pvcreate /dev/sda1

  Can't open /dev/sda1 exclusively.  Mounted filesystem?

lvm> 

lvm> quit

  Exiting.

 

 

root@ubuntu:/home/zhangbin# df -;

df: `-': No such file or directory

df: no file systems processed

root@ubuntu:/home/zhangbin# df -l

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1             19737268  17853404    881268  96% /

none                    250352       256    250096   1% /dev

none                    254580       168    254412   1% /dev/shm

none                    254580       112    254468   1% /var/run

none                    254580         0    254580   0% /var/lock

none                    254580         0    254580   0% /lib/init/rw

root@ubuntu:/home/zhangbin# fdisk -l

 

Disk /dev/sda: 26.8 GB, 26843545600 bytes

255 heads, 63 sectors/track, 3263 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00030124

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1        2497    20051968   83  Linux

/dev/sda2            2497        2611      916481    5  Extended

/dev/sda3            2612        3263     5237190   83  Linux

/dev/sda5            2497        2611      916480   82  Linux swap / Solaris

root@ubuntu:/home/zhangbin# 

root@ubuntu:/home/zhangbin# vgdisplay VolGroup00

  Volume group "VolGroup00" not found

 

 

vmware提供的磁碟管理工具。

其實用圖形介面就行。

C:/Program Files/VMware/VMware Workstation>vmware-vdiskmanager

VMware Virtual Disk Manager - build 385536.

Usage: vmware-vdiskmanager.exe OPTIONS <disk-name> | <mount-point>

Offline disk manipulation utility

  Operations, only one may be specified at a time:

     -c                   : create disk.  Additional creation options must

                            be specified.  Only local virtual disks can be

                            created.

     -d                   : defragment the specified virtual disk. Only

                            local virtual disks may be defragmented.

     -k                   : shrink the specified virtual disk. Only local

                            virtual disks may be shrunk.

     -n <source-disk>     : rename the specified virtual disk; need to

                            specify destination disk-name. Only local virtual

                            disks may be renamed.

     -p                   : prepare the mounted virtual disk specified by

                            the mount point for shrinking.

     -r <source-disk>     : convert the specified disk; need to specify

                            destination disk-type.  For local destination disks

                            the disk type must be specified.

     -x <new-capacity>    : expand the disk to the specified capacity. Only

                            local virtual disks may be expanded.

     -R                   : check a sparse virtual disk for consistency and atte

mpt

                            to repair any errors.

     -D                   : make disk deletable.  This should only be used on di

sks

                            that have been copied from another product.

 

  Other Options:

     -q                   : do not log messages

 

  Additional options for create and convert:

     -a <adapter>         : (for use with -c only) adapter type

                            (ide, buslogic, lsilogic). Pass lsilogic for other a

dapter types.

     -s <size>            : capacity of the virtual disk

     -t <disk-type>       : disk type id

 

  Options for remote disks:

     -h <hostname>        : hostname of remote server

     -u <username>        : username for remote server

     -f <filename>        : file containing password

     -P <port>            : optional TCP port number (default: 902)

     -S                   : specifies that the source disk is remote, by default

 

                            the remote options are assumed to refer to the

                            destination.

  Disk types:

      0                   : single growable virtual disk

      1                   : growable virtual disk split in 2GB files

      2                   : preallocated virtual disk

      3                   : preallocated virtual disk split in 2GB files

      4                   : preallocated ESX-type virtual disk

      5                   : compressed disk optimized for streaming

      6                   : thin provisioned virtual disk - ESX 3.x and above

 

     The capacity can be specified in sectors, KB, MB or GB.

     The acceptable ranges:

                           ide adapter : [1MB, 2040.0GB]

                           scsi adapter: [1MB, 2040.0GB]

        ex 1: vmware-vdiskmanager.exe -c -s 850MB -a ide -t 0 myIdeDisk.vmdk

        ex 2: vmware-vdiskmanager.exe -d myDisk.vmdk

        ex 3: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 0 destinationDisk.vm

dk

        ex 4: vmware-vdiskmanager.exe -x 36GB myDisk.vmdk

        ex 5: vmware-vdiskmanager.exe -n sourceName.vmdk destinationName.vmdk

        ex 6: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 4 -h esx-name.mycomp

any.com /

              -u username -f passwordfile "[storage1]/path/to/targetDisk.vmdk"

        ex 7: vmware-vdiskmanager.exe -k myDisk.vmdk

        ex 8: vmware-vdiskmanager.exe -p <mount-point>

              (A virtual disk first needs to be mounted at <mount-point>)

 

 

C:/Program Files/VMware/VMware Workstation>

 

===================================================================

 

 

 

disk utiltiy顯示介面很大,而且固定,經常超過我800*600的顯示區域,因此考慮換gparted。

gparted很牛的。但是調整/的大小,因為/不能被解除安裝,所以要考慮其他方案。

 

 

這位前輩,用gparted很好的解決了分割槽的問題。他採用的是iso啟動的方案。寫了一個手記。

http://hi.baidu.com/%CB%E9%C6%AC1987/blog/item/794af883cae5c4dc9023d945.html

 

 

====================================================

以下是我的過程:

 

iso和啟用光碟機。

光碟機iso

 

 

 

這樣就制定了光碟機的iso檔案。

採用但是gparted的live iso,很牛逼啊。都做成一個iso了。

 

開機在vmware白字黑螢幕哪裡,按F2,啟動bios,設定從光碟機啟動,但是一直都不行。

在ubuntu中,啟用了一個下有效較的那個光碟icon,ubuntu10.04識別到了光碟機內容,說明了兩點:

1.需要點選光碟icon,啟用vmware的光碟機讀取。

2.gparted的iso映象是好的,用google chrome下載檔案,達到了104KB/s左右,但是沒有卡。

而用qq傳遞檔案,還不到40KB/s,以及迅雷下載不論多小的檔案,都會讓網路變得很卡。

不知道問題出在什麼地方。

 

==================================================================

啟用了光碟機之後。

 

啟動gparted livecd 

重啟,就出來了gparted livecd 的介面,很炫。

還有很多小工具。

 

用gparted的預設設定啟動:

首先要求設定keymap,鍵盤對映麼?

直接按回車。

keymap

 

 

 

26是簡體中文,預設是usa英文。

 

用漢語

 

 

漢語

 

預設的0是x11介面。

 

看到這個介面,我陶醉了。

我刪掉了swap 分割槽。

刪掉了lvm分割槽。(之前在lvm裡頭,我把5G的分割槽,設定為lvm了。)

然後就等待合併了,否則/不能移動大小。

很牛啊

 

 

這是在ubunt10.04上gparted的:  邏輯卷不支援。

 

lvm

 

 

虛擬機器預設的ubuntu系統用512M記憶體,swap就設定為256好了。

 

 

分割槽

 

swap

 

 

swap預設是作為主分割槽的。

我覺得都行吧。

boot還行也沒有被我獨立出來,而是在/中了。

主分割槽

 

 

 

過程

 

 

 

分割槽後:

sda擴大

 

 

 

 

gparetd的live cd 是個很好的工具箱。

 

退出menu----shutdown了。

 

關機

 

按回車,然後就顯示 now  halt。。。。。。。。。

 

看一下情況:

 

情況

 

 

相關文章