自制Linux操作系统

                                          作者:尹正杰

版权声明:原创作品,谢绝转载!否则将追究法律责任。

 

 

一.添加一块新的磁盘设备

1>.将虚拟机关机,点击"编辑虚拟机设置"

自制Linux操作系统

2>.点击"添加"按钮

自制Linux操作系统

3>.选择添加虚拟硬件的类型为"硬盘"并点击下一步

自制Linux操作系统

4>.点击下一步

自制Linux操作系统

5>.点击下一步

自制Linux操作系统

6>.点击"将虚拟磁盘存储为单个文件"并点击下一步

自制Linux操作系统

7>.自定义新硬盘的名称

自制Linux操作系统

8>.点击保存按钮

自制Linux操作系统

9>.启动虚拟机

自制Linux操作系统

 

二.分区并创建文件系统

1>.查看硬盘资源

[root@yinzhengjie ~]# lsblk 
NAME                          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0                            11:0    1   3.7G  0 rom  
sda                             8:0    0   500G  0 disk 
├─sda1                          8:1    0   500M  0 part /boot
└─sda2                          8:2    0 499.5G  0 part 
  ├─vg_node200-lv_root (dm-0) 253:0    0    50G  0 lvm  /
  ├─vg_node200-lv_swap (dm-1) 253:1    0   3.9G  0 lvm  [SWAP]
  └─vg_node200-lv_home (dm-2) 253:2    0 445.7G  0 lvm  /home
sdb                             8:16   0    20G  0 disk 
[root@yinzhengjie ~]# 

2>.使用fdisk命令对sdb硬盘进行分区操作

[root@yinzhengjie ~]# lsblk 
NAME                          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0                            11:0    1   3.7G  0 rom  
sda                             8:0    0   500G  0 disk 
├─sda1                          8:1    0   500M  0 part /boot
└─sda2                          8:2    0 499.5G  0 part 
  ├─vg_node200-lv_root (dm-0) 253:0    0    50G  0 lvm  /
  ├─vg_node200-lv_swap (dm-1) 253:1    0   3.9G  0 lvm  [SWAP]
  └─vg_node200-lv_home (dm-2) 253:2    0 445.7G  0 lvm  /home
sdb                             8:16   0    20G  0 disk 
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# fdisk /dev/sdb 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xbebd0e26.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +1G

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xbebd0e26

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         132     1060258+  83  Linux

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (133-2610, default 133): 
Using default value 133
Last cylinder, +cylinders or +size{K,M,G} (133-2610, default 2610): +10G

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xbebd0e26

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         132     1060258+  83  Linux
/dev/sdb2             133        1438    10490445   83  Linux

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1439-2610, default 1439): 
Using default value 1439
Last cylinder, +cylinders or +size{K,M,G} (1439-2610, default 2610): +2G

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 82
Changed system type of partition 3 to 82 (Linux swap / Solaris)

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0xbebd0e26

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         132     1060258+  83  Linux
/dev/sdb2             133        1438    10490445   83  Linux
/dev/sdb3            1439        1700     2104515   82  Linux swap / Solaris

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# lsblk 
NAME                          MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sr0                            11:0    1   3.7G  0 rom  
sda                             8:0    0   500G  0 disk 
├─sda1                          8:1    0   500M  0 part /boot
└─sda2                          8:2    0 499.5G  0 part 
  ├─vg_node200-lv_root (dm-0) 253:0    0    50G  0 lvm  /
  ├─vg_node200-lv_swap (dm-1) 253:1    0   3.9G  0 lvm  [SWAP]
  └─vg_node200-lv_home (dm-2) 253:2    0 445.7G  0 lvm  /home
sdb                             8:16   0    20G  0 disk 
├─sdb1                          8:17   0     1G  0 part 
├─sdb2                          8:18   0    10G  0 part 
└─sdb3                          8:19   0     2G  0 part 
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# 
[root@yinzhengjie ~]# fdisk /dev/sdb

相关文章: