linux添加磁盘空间


首先你要关掉系统,把分配的硬盘空间变大,或者重新建立一个虚拟硬盘(这时下面的就不是sda了,而是sdb1了)。这两种方法都可行,我都试过了。
其次用root用户登录到你的linux系统,查看你系统的分区
#fdisk-l
会出现以下的信息:
Device BootStartEndBlocksIdSystem
/dev/sda1*16451200083Linux
/dev/sda2642611204584968eLinux LVM

Disk /dev/mapper/vg_zxw-lv_root: 18.8 GB, 18832424960 bytes
255 heads, 63 sectors/track, 2289 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/mapper/vg_zxw-lv_root doesn't contain a valid partition table

Disk /dev/mapper/vg_zxw-lv_swap: 2113 MB, 2113929216 bytes
255 heads, 63 sectors/track, 257 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/mapper/vg_zxw-lv_swap doesn't contain a valid partition table
根据提示信息可以判断出此系统的磁盘接口为SCSI,对应“sda”如果上面的红色字体是“hda”,那么此系统的磁盘接口为IDE对应“hda”所以我做一下操作:

#fdisk/dev/sda

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):m//“ 列出fdisk的帮助”
Command action
atoggle a bootable flag
bedit bsd disklabel
ctoggle the dos compatibility flag
ddelete a partition
llist known partition types
mprint this menu
nadd a new partition
ocreate a new empty DOS partition table
pprint the partition table
qquit without saving changes
screate a new empty Sun disklabel
tchange a partition's system id
uchange display/entry units
vverify the partition table
wwrite table to disk and exit
xextra functionality (experts only)

Command (m for help):n//” 命令n用于添加新分区"
Command action
eextended
pprimary partition (1-4)
p//" 选择创建主分区"此时,

Partition number (1-4):3//fdisk会让你选择主分区的编号,如果已经有了主分区sda1,sda2,那么编号就选3,即要创建的该分区为sda3.
First cylinder (2611-3916, default 2611)://此时,fdisk又会让你选择该分区的开始值这个就是分区的Start 值(start cylinder);这里最好直接按回车,
Using default value 2611
Last cylinder, +cylinders or +size{K,M,G} (2611-3916, default 3916)://此时,fdisk又会让你选择该分区的开始值这个就是分区的End值这里最好直接按回车,
Using default value 3916

Command (m for help):w//w "保存所有并退出,分区划分完毕"
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
三、我们的新建分区/dev/sda3,却不是LVM的。所以,接下来使用fdisk将其改成LVM的。
#fdisk/dev/sda
Command (m for help): m
Command (m for help): t //改变分区系统id

Partition number (1-4): 3 //指定分区号
Hex code (type L to list codes): 8e //指定要改成的id号,8e代表LVM。
Command (m for help): w
三、重启系统后,登陆系统。(一定要重启系统,否则无法扩充新分区)
四、格式化该新添加的分区:
#fdisk-l

Device BootStartEndBlocksIdSystem
/dev/sda1*16451200083Linux
/dev/sda2642611204584968eLinux LVM
/dev/sda326113916104837508eLinux LVM
你会发现多了一块分区。
#mkfs-text3/dev/sda3//在硬盘分区“/dev/sda3”上创建“ext3”文件系统。
然后我们把这个分区挂载到本系统上:

五、使用命令mount

mount -t ext3 /dev/sda3 /mnt/disk2

这里的disk2,是自己建立的要挂载的目录,不知道如何使用该命令的可以使用man命令查看。man mount。

优质内容筛选与推荐>>
1、Codeforces 1156D 0-1-Tree(树形dp)
2、sql server 常用sql
3、JAVA中自定义日志输出到指定文件
4、HTML <form> 标签
5、【笔记】应用程序中使用系统主题外观


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号