- 积分
- 824
- 鸿鹄币
- 个
- 好评度
- 点
- 精华
- 最后登录
- 1970-1-1
- 阅读权限
- 40
- 听众
- 收听
中级工程师
   
|
发表于 2014-3-4 00:16:19
|
显示全部楼层
luna挂载新硬盘操作流程
1、查看你的系统有多少块硬盘,并确定那块硬盘是需要重新格式化和重新分区等等;
alia@alia:~$ sudo fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes ----系统安装的硬盘,后面可以看到分区的情况等
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0009812d
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 968714239 484356096 83 Linux
/dev/sda2 968716286 976771071 4027393 5 Extended
Partition 2 does not start on physical sector boundary.
/dev/sda5 968716288 976771071 4027392 82 Linux swap / Solaris
Disk /dev/sdb: 20.0 GB, 20014718976 bytes ----可以看到有一块新的硬盘还没有分区及挂载到系统上
81 heads, 63 sectors/track, 7660 cylinders, total 39091248 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 identifier: 0x000d1bdb
2、使用fdisk工具进行对新硬盘进行分区和格式化
alia@alia:~$ sudo fdisk /dev/sdb
Command (m for help): m ----输入m显示帮助命令
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): n ---输入n新建一个分区
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): p ---分区模式选择主分区
Partition number (1-4, default 2): 1 ----选择分区号
Partition 1 is already defined. Delete it before re-adding it.
Command (m for help): m ----输入m显示帮助命令
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
Command (m for help): w ---写进分区表进退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
alia@alia:~$
alia@alia:~$ sudo fdisk -l
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x0009812d
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 968714239 484356096 83 Linux
/dev/sda2 968716286 976771071 4027393 5 Extended
Partition 2 does not start on physical sector boundary.
/dev/sda5 968716288 976771071 4027392 82 Linux swap / Solaris
Disk /dev/sdb: 20.0 GB, 20014718976 bytes
81 heads, 63 sectors/track, 7660 cylinders, total 39091248 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 identifier: 0x000d1bdb
Device Boot Start End Blocks Id System
/dev/sdb1 2048 39091247 19544600 83 Linux ---通过fdisk检查可以看到刚刚新建的分区/dev/sdb1
alia@alia:~$
alia@alia:~$ sudo mkfs.ext4 /dev/sdb1 ----格式化刚才新建的分区(分区的格式选择了ext4),新建分区需要格式化后才能挂载到系统
mke2fs 1.42 (29-Nov-2011)
Discarding device blocks: 完成
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
1221600 inodes, 4886150 blocks
244307 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=4294967296
150 block groups
32768 blocks per group, 32768 fragments per group
8144 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
alia@alia:~$
alia@alia:~$ sudo mkdir /ssd_disk/ ----创建一个挂接目录(用于新硬盘分区挂接至系统分区目录)
alia@alia:~$ sudo mount /dev/sdb1 /ssd_disk ----将ssd硬盘分挂接至系统/ssd_disk目录
alia@alia:~$
alia@alia:~$ df -lh ----检查分区挂接情况
文件系统 容量 已用 可用 已用% 挂载点
/dev/sda1 455G 4.0G 428G 1% /
udev 1.9G 4.0K 1.9G 1% /dev
tmpfs 760M 844K 759M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 1.9G 232K 1.9G 1% /run/shm
/dev/sdb1 19G 172M 18G 1% /ssd_disk ----看到新硬盘分区已挂接到系统/ssd_disk目录下
alia@alia:~$
3、实现开机系统自动挂载新硬盘新区
alia@alia:~$ vi /etc/fstab ----在文件最后一行新加如下命令即可
/dev/sdb1 /ssd_disk ext4 defaults 1 1
|
40#
2014-3-4 00:16:19
回复(0)
收起回复
|