linux挂载磁盘

阅读次数: 3,565

  • A+
所属分类:LINUX 运维

新买的云服务器默认都是没有挂载磁盘的


先查看磁盘信息


fdisk -l

Disk /dev/sdb: 161.1 GB, 161061273600 bytes
255 heads, 63 sectors/track, 19581 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/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x000573b9

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 1306 9972736 8e Linux LVM

Disk /dev/mapper/vg_cloud-lv_root: 9135 MB, 9135194112 bytes
255 heads, 63 sectors/track, 1110 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/vg_cloud-lv_swap: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00000000

查看到我这里有两个硬盘

一个/dev/sda

一个 /dev/sdb


查看挂载信息


df -h

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_cloud-lv_root
8.3G 4.8G 3.1G 61% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
/dev/sda1 477M 38M 414M 9% /boot
/dev/sdb 148G 189M 140G 1% /data

显示的是当前的磁盘占用情况

我这里是已经挂载好的了

如果没有挂载好则  没有  /dev/sdb 148G 189M 140G 1% /data  这个的


开始挂载


mkdir /new #生成临时挂载点

mount /dev/sdb /new #挂载(注意此时会出错如果磁盘没有格式化

cp -R /data/* /new #复制原有data的原有文件

rm -rf /data/* #删除现有文件

mount /dev/sdb /data #转移挂载点

umount /new #删除原有挂载点

rm -rf /new #删除临时文件

echo "/dev/sdb /data ext3 defaults 0 0" >> /etc/fstab #加入开机启动


磁盘格式化


mkfs.ext3 /dev/sdb

 

  • 我的微信
  • 这是我的微信扫一扫
  • weinxin
  • 我的微信公众号
  • 我的微信公众号扫一扫
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: