仮想マシンのHDDの増設方法

VMware Playerで、仮想マシンのHDDを増設する方法のメモ ※ゲストOSが ubunntu の場合

ディスクの確認

$ sudo fdisk -l
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcd164bd0

デバイス   起動     Start 最後から セクタ  Size Id タイプ
/dev/sda1  *         2048 125065215 125063168 59.7G 83 Linux
/dev/sda2       125065216 125827071    761856  372M  5 拡張領域
/dev/sda5       125067264 125827071    759808  371M 82 Linux スワップ / Solaris

パーティションの作成

$ sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x49de55dd.

コマンド (m でヘルプ): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
パーティション番号 (1-4, default 1): 1
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039):

Created a new partition 1 of type 'Linux' and of size 20 GiB.

コマンド (m でヘルプ): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

ディスクの確認(その2)

$ sudo fdisk -l
Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x49de55dd

デバイス   起動 Start 最後から セクタ Size Id タイプ
/dev/sdb1        2048 41943039 41940992  20G 83 Linux


Disk /dev/sda: 60 GiB, 64424509440 bytes, 125829120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcd164bd0

デバイス   起動     Start 最後から セクタ  Size Id タイプ
/dev/sda1  *         2048 125065215 125063168 59.7G 83 Linux
/dev/sda2       125065216 125827071    761856  372M  5 拡張領域
/dev/sda5       125067264 125827071    759808  371M 82 Linux スワップ / Solaris

ファイルシステムの確認

$ df -T
Filesystem     Type             1K-blocks      Used Available Use% Mounted on
udev           devtmpfs           1992168         0   1992168   0% /dev
tmpfs          tmpfs               402848      6380    396468   2% /run
/dev/sda1      ext4              61417484  51250292   7024236  88% /
tmpfs          tmpfs              2014232       252   2013980   1% /dev/shm
tmpfs          tmpfs                 5120         4      5116   1% /run/lock
tmpfs          tmpfs              2014232         0   2014232   0% /sys/fs/cgroup
vmhgfs-fuse    fuse.vmhgfs-fuse 499137532 427050968  72086564  86% /mnt/hgfs
tmpfs          tmpfs               402848        72    402776   1% /run/user/1000

ディスクのフォーマット

$ sudo mkfs.ext4 /dev/sdb1
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 5242624 4k blocks and 1310720 inodes
Filesystem UUID: ecb66f90-1919-4e33-ba58-3af8b21d909e
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

ディスクのマウント

$ sudo mkdir /mnt/tmp_hdd
$ sudo mount /dev/sdb1 /mnt/tmp_hdd
$ df -T
Filesystem     Type             1K-blocks      Used Available Use% Mounted on
udev           devtmpfs           1992168         0   1992168   0% /dev
tmpfs          tmpfs               402848      6384    396464   2% /run
/dev/sda1      ext4              61417484  51250280   7024248  88% /
tmpfs          tmpfs              2014232       252   2013980   1% /dev/shm
tmpfs          tmpfs                 5120         4      5116   1% /run/lock
tmpfs          tmpfs              2014232         0   2014232   0% /sys/fs/cgroup
vmhgfs-fuse    fuse.vmhgfs-fuse 499137532 427063796  72073736  86% /mnt/hgfs
tmpfs          tmpfs               402848        68    402780   1% /run/user/1000
/dev/sdb1      ext4              20510332     44992  19400432   1% /mnt/tmp_hdd

OS起動時に自動でマウントする場合

$ sudo blkid /dev/sdb1
/dev/sdb1: UUID="ecb66f90-1919-4e33-ba58-3af8b21d909e" TYPE="ext4" PARTUUID="49de55dd-01"

$ sudo nano /etc/fstab

UUID=ecb66f90-1919-4e33-ba58-3af8b21d909e	/mnt/tmp_hdd	ext4	defaults	0	0

追加前の状態

$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda1 during installation
UUID=18263217-3d19-4d6f-be64-10dfe87dd017 /               ext4    errors=remount-ro 0       1
# swap was on /dev/sda5 during installation
UUID=c3aa15ec-7b09-4eef-a69c-d497d656eb02 none            swap    sw              0       0

トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS