CentOS挂载新硬盘
2014-06-13 19:31
316 查看
1.查看当前硬盘使用状况:
2.查看新硬盘
这结果很明显让人烦躁,一坨屎一样,下面我们过滤一下
命令:
结果:
这个看起来让人舒心多了,
结果中:
提示这个
这两行应该就是说还没有挂载上去的硬盘了.
新添加的硬盘的编号为
3.硬盘分区
进入fdisk模式
输入n进行分区
这里有两个选项:
p: 主分区 linux上主分区最多能有4个
e: 扩展分区 linux上扩展分区只能有1个,扩展分区创建后不能直接使用,还要在扩展分区上创建逻辑分区。
这里我选择的p。
选择分区个数
可以选择4个分区,这里我只分成1个分区
设置柱面,这里选择默认值就可以,直接按回车过去
输入w,写入分区表,进行分区
整个过程如下:
4.格式化分区
将新分区格式化为ext3文件系统
如果创建的是主分区
5. 挂载硬盘
创建挂载点
在根目录下创建storage目录
将/dev/xvdb挂载到/storage下
设置开机启动自动挂载
新创建的分区不能开机自动挂载,每次重启机器都要手动挂载。
设置开机自动挂载需要修改/etc/fstab文件
在文件的最后增加一行
过程如下:
结果:
教程到此结束!
df -h
root@VM_160_34_centos:~> df -h Filesystem Size Used Avail Use% Mounted on /dev/xvda1 7.9G 1.5G 6.1G 20% /
2.查看新硬盘
fdisk -l
root@VM_160_34_centos:~> fdisk -l Disk /dev/xvda: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 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: 0xcd6e8236 Device Boot Start End Blocks Id System /dev/xvda1 * 1 1044 8385898+ 83 Linux Disk /dev/xvdb: 53.7 GB, 53687091200 bytes 255 heads, 63 sectors/track, 6527 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: 0x00000000 Disk /dev/xvdb doesn't contain a valid partition table Disk /dev/xvdc: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 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: 0x00000000 Disk /dev/xvdc doesn't contain a valid partition table
这结果很明显让人烦躁,一坨屎一样,下面我们过滤一下
命令:
fdisk -l |grep Disk
结果:
root@VM_160_34_centos:~>fdisk -l |grep Disk
Disk /dev/xvdb doesn't contain a valid partition table Disk /dev/xvdc doesn't contain a valid partition table
Disk /dev/xvda: 8589 MB, 8589934592 bytes
Disk identifier: 0xcd6e8236
Disk /dev/xvdb: 53.7 GB, 53687091200 bytes
Disk identifier: 0x00000000
Disk /dev/xvdc: 2147 MB, 2147483648 bytes
Disk identifier: 0x00000000
这个看起来让人舒心多了,
结果中:
提示这个
Disk /dev/xvdb doesn't contain a valid partition table Disk /dev/xvdc doesn't contain a valid partition table
这两行应该就是说还没有挂载上去的硬盘了.
新添加的硬盘的编号为
/dev/xvdb
/dev/xvdc
3.硬盘分区
进入fdisk模式
fdisk /dev/xvdb
root@VM_160_34_centos:~> fdisk /dev/xvdb Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x7ca79642. 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 (m for help): n Command action e extended p primary partition (1-4) p
这里有两个选项:
p: 主分区 linux上主分区最多能有4个
e: 扩展分区 linux上扩展分区只能有1个,扩展分区创建后不能直接使用,还要在扩展分区上创建逻辑分区。
这里我选择的p。
选择分区个数
Partition number (1-4): 1
可以选择4个分区,这里我只分成1个分区
设置柱面,这里选择默认值就可以,直接按回车过去
First cylinder (1-6527, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-6527, default 6527): Using default value 6527
输入w,写入分区表,进行分区
Command (m for help):w
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
整个过程如下:
root@VM_160_34_centos:~> fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x7ca79642.
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)
Last login: Fri Jun 13 18:19:47 2014 from 112.90.239.105
root@VM_160_34_centos:~>
Display all 1286 possibilities? (y or n)
root@VM_160_34_centos:~>
root@VM_160_34_centos:~> fdisk /dev/xvd
xvda xvda1 xvdb xvdc
root@VM_160_34_centos:~> fdisk /dev/xvdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc925c1ae.
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-6527, default 1): Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-6527, default 6527): Using default value 6527
Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
4.格式化分区
将新分区格式化为ext3文件系统
如果创建的是主分区
#mkfs -t ext3 /dev/xvdb
root@VM_160_34_centos:~> mkfs -t ext3 /dev/xvdb mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 3276800 inodes, 13107200 blocks 655360 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 400 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424 Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 39 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
5. 挂载硬盘
创建挂载点
在根目录下创建storage目录
#mkdir /storage
将/dev/xvdb挂载到/storage下
#mount /dev/xvdb /storage
设置开机启动自动挂载
新创建的分区不能开机自动挂载,每次重启机器都要手动挂载。
设置开机自动挂载需要修改/etc/fstab文件
#vi /etc/fstab
在文件的最后增加一行
/dev/xvdb /storage ext3 defaults 1 2
过程如下:
root@VM_160_34_centos:~> mkdir /storage root@VM_160_34_centos:~> mount /dev/xvdb /storage root@VM_160_34_centos:~> vi /etc/fstab /dev/xvda1 / ext3 noatime,acl,user_xattr 1 1 /dev/xvdc swap swap defaults 0 0 proc /proc proc defaults 0 0 sysfs /sys sysfs noauto 0 0 debugfs /sys/kernel/debug debugfs noauto 0 0 devpts /dev/pts devpts mode=0620,gid=5 0 0 /dev/xvdb /storage ext3 defaults 1 2 ~ ~ ~ ~ ~ "/etc/fstab" 7L, 536C written root@VM_160_34_centos:~> clear
结果:
root@VM_160_34_centos:/storage> ll /
total 104
dr-xr-xr-x 2 root root 4096 May 15 15:33 bin
dr-xr-xr-x 4 root root 4096 May 31 2013 boot
drwxr-xr-x 2 root root 4096 Dec 16 11:42 data
drwxr-xr-x 15 root root 3360 Jun 13 19:21 dev
drwxr-xr-x 73 root root 4096 Jun 13 19:37 etc
drwxr-xr-x 3 root root 4096 Jun 2 20:32 home
dr-xr-xr-x 12 root root 4096 Jun 20 2013 lib
dr-xr-xr-x 9 root root 12288 Jun 20 2013 lib64
drwx------ 2 root root 16384 May 31 2013 lost+found
drwxr-xr-x 2 root root 4096 Sep 23 2011 media
drwxr-xr-x 2 root root 4096 Sep 23 2011 mnt
drwxr-xr-x 2 root root 4096 Sep 23 2011 opt
dr-xr-xr-x 106 root root 0 Jun 14 2014 proc
dr-xr-x--- 2 root root 4096 Jun 13 19:35 root
dr-xr-xr-x 2 root root 12288 Jun 19 2013 sbin
drwxr-xr-x 2 root root 4096 May 31 2013 selinux
drwxr-xr-x 2 root root 4096 Sep 23 2011 srv
drwxr-xr-x 3 root root 4096 Jun 13 19:37 storage
drwxr-xr-x 13 root root 0 Jun 14 2014 sys
drwxrwxrwt 3 root root 4096 Jun 13 18:26 tmp
drwxr-xr-x 13 root root 4096 May 31 2013 usr
drwxr-xr-x 19 root root 4096 Jul 16 2013 var
root@VM_160_34_centos:/storage>fdisk -l |grep Disk
Disk /dev/xvdb doesn't contain a valid partition table Disk /dev/xvdc doesn't contain a valid partition table
Disk /dev/xvda: 8589 MB, 8589934592 bytes
Disk identifier: 0xcd6e8236
Disk /dev/xvdb: 53.7 GB, 53687091200 bytes
Disk identifier: 0x00000000
Disk /dev/xvdc: 2147 MB, 2147483648 bytes
Disk identifier: 0x00000000
root@VM_160_34_centos:/storage> df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.9G 1.5G 6.1G 20% /
/dev/xvdb 50G 180M 47G 1% /storage
教程到此结束!
相关文章推荐
- CentOS 新增加硬盘挂载并开机自动挂载
- CentOS挂载NTFS格式硬盘
- centos系统中挂载盘和扩容硬盘的方法
- CentOS 6.5挂载windows NTFS硬盘
- CentOS6.5系统挂载NTFS分区的移动硬盘
- Linux(CentOS)挂载移动硬盘,实现文件拷贝、备份
- CentOS添加一个新的硬盘分区到挂载的过程
- 星外vps-centos系统挂载硬盘
- CentOS挂载U盘、移动硬盘以及文件拷贝、备份
- centos7.2 挂载NTFS格式移动硬盘
- CentOS添加一个新的硬盘分区到挂载的过程
- centos 挂载U盘移动硬盘
- CentOS 格式化新硬盘并设置开机自动挂载
- centos 挂载与卸载硬盘
- centos7.2 挂载NTFS移动硬盘
- centos 6 挂载nfts硬盘
- CentOS挂载新硬盘
- Centos如何挂载硬盘
- CentOS6.5系统挂载NTFS分区的移动硬盘 centos安装repoforge源(yum)
- centos 6.8 挂载NTFS移动硬盘