7.Linux swap分区的使用,主引导记录(MBR)的备份、dd,df,du命令的使用

         对Linux而言,虚拟内存必须是独立的文件系统,因此只能用分区来提供虚拟内存。

 

root@ubuntu:~# fdisk-l
 
Disk /dev/sda: 21.5GB, 21474836480 bytes
255 heads, 63sectors/track, 2610 cylinders, total 41943040 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:0x0007ef80
 
 Device    Boot     Start         End      Blocks   Id   System
/dev/sda1   *       2048    39845887    19921920  83  Linux
/dev/sda2        39847934    41940991    1046529    5  Extended
/dev/sda3        39845888    39847933        1023  83  Linux
/dev/sda5        39849982    41940991    1045505   83  Linux
 
Partition tableentries are not in disk order


 

#每种分区的ID字段是不一样的,要想修改分区类型就要修改分区的ID

 

         修改分区类别:

root@ubuntu:~# fdisk/dev/sda
 
Command (m for help):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   verifythe partition table
   w  write table to disk and exit
   x  extra functionality (experts only)
 
Command (m for help):t
Partition number(1-5): 5
Hex code (type L to listcodes): 82            #修改/dev/sda5为swap分区(swap分区的标识为82)
Changed system typeof partition 5 to 82 (Linux swap / Solaris)
 
Command (m for help):w
The partition tablehas been altered!
 
Calling ioctl() tore-read partition table.
 
WARNING: Re-readingthe partition table failed with error 16: Device or resource busy.
The kernel still usesthe old table. The new table will be used at
the next reboot orafter you run partprobe(8) or kpartx(8)
Syncing disks.


 

修改分区属性之后,我们还要将/dev/sda5创建为swap文件系统才能使用:

root@ubuntu:~# mkswap/dev/sda5      #创建为swap文件系统
Setting up swapspaceversion 1, size = 1045500 KiB
no label,UUID=f33720ed-3b0c-46e1-a898-c7f4cb9adfb8
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值