今天被坑了,给一个同事安装win8系统时,到一半说不能安装在GPT分区上面,下面讲如何解决:

  把GPT磁盘转换为MBR磁盘,安装系统到提示你不能安装在那个磁盘的一步, 在选择分区界面,按下SHIFT+F10调出命令提示符

win8安装磁盘采用GPT分区形式解决方法,重置win7登录密码,用fdisk与parted对不同容量硬盘分区_xitong

键入 diskpart

打开diskpart工具  

★选择目标磁盘

list disk--------------------列出系统拥有的磁盘

select disk 0 --------------选择0号磁盘,请根据磁盘大小,自行判断你的目标磁盘  

win8安装磁盘采用GPT分区形式解决方法,重置win7登录密码,用fdisk与parted对不同容量硬盘分区_xitong_02

★清空目标磁盘,并转换为MBR格式

clean-------------------------清除磁盘,该命令会抹去磁盘上所有数据

convert mbr------------------将磁盘转换为GPT格式

list partition-----------------列出磁盘上的分区,因为我们刚转换成mbr格式,因此,分区为空  

PS:其实,一个diskpart工具,几乎可以代替其他的第三方磁盘工具了,比如著名的DiskGenius,是无法更改GPT格式磁盘的分区ID的,但是diskpart可以。

PS:在安装MAC系统的时候,需要更改分区ID。

PS:关于diskpart的详细使用,可以在diskpart中键入help查看


做完上边的操作,回到安装界面,刷新一下,按着以前的安装方式直接安装系统就可以了。



centos安装不支持GPT模式如何处理

安装centos 5.x ,分区时系统报下面的提示,不支持GPT ,无法分区。

提示:

Your boot partition is on a disk using the GPT partitioning Scheme but this machines cannot boot using GPT.

解决方法:

用快捷键:Ctrl+Alt+F2到命令界面:

查看硬盘的设备名称:

fdisk -l

 

假设是/dev/sda后面显示的类型是GPT,输入:

parted

 再输入:

select

 

再输入:

 /dev/sda(不要选择sda1或sda2什么的,只输入sda即可)

输入:mklabel msdos

输入:yes

Your disk type?[gpt]?

输入:

Msdos(很重要)

quit

重启服务器,

然后重新格式化所要安装的磁盘,安装即可。




重置修改已经忘记的Windows 7登录密码方法教程

忘记windows登录密码是件悲催的事情,不过还好有方法重置密码,不用重装系统也能继续使用。

win8安装磁盘采用GPT分区形式解决方法,重置win7登录密码,用fdisk与parted对不同容量硬盘分区_xitong_03

重置准备:一个windows 7安装介质(光盘和U盘都可以),如果你没有windows 7安装介质,那就没必要继续下面的步骤了。

插入windows 7安装介质,并选择从安装介质启动,然后选择修复计算机,

win8安装磁盘采用GPT分区形式解决方法,重置win7登录密码,用fdisk与parted对不同容量硬盘分区_xitong_04

然后选择命令提示符,

win8安装磁盘采用GPT分区形式解决方法,重置win7登录密码,用fdisk与parted对不同容量硬盘分区_xitong_05

在弹出的命令提示符窗口中输入下面命令并回车,

copy c:\windows\system32\sethc.exe c:\

请注意此处c代表系统盘符,如果提示找不到文件,请找到系统盘的正确盘符。该命令是将粘滞键执行文件备份,接着输入下面的命令并回车,

copy c:\windows\system32\cmd.exe c:\windows\system32\sethc.exe

该命令是将命令提示符执行文件替换掉粘滞键执行文件,完成后可以看到下图的提示。

win8安装磁盘采用GPT分区形式解决方法,重置win7登录密码,用fdisk与parted对不同容量硬盘分区_xitong_06

现在重启你的电脑并直接进入原有windows 7系统,在登录界面连按五次Shift键会弹出命令提示符窗口,

win8安装磁盘采用GPT分区形式解决方法,重置win7登录密码,用fdisk与parted对不同容量硬盘分区_xitong_07

接着输入重置密码命令,输入完成后回车,

net user 你的用户名 新密码

其中用户名是你登录windows 7时使用的用户名(即密码方框上方显示的名称),新密码是用来登录系统使用的。


win8安装磁盘采用GPT分区形式解决方法,重置win7登录密码,用fdisk与parted对不同容量硬盘分区_xitong_08

提示命令成功后,现在你可以使用刚才设置的新密码登录系统。当然为了防止登录界面能继续重置密码,你还需要将之前替换的粘滞键执行文件还原。插入windows 7安装介质,选择修复计算机并选择命令提示符,在打开命令提示符后输入  copy c:\sethc.exe c:\windows\system32\sethc.exe


如何使用fdisk与parted对不同容量硬盘分区

一、简介

通常我们用的比较多的一般都是fdisk工具来进行分区,但是现在由于磁盘越来越廉价,而且磁盘空间越来越大;而fdisk工具他对分区是有大小限制的,它只能划分小于2T的磁盘。如果使用fdisk对大于2T的磁盘分区,虽然可以分区,但仅识别2T的空间,所以磁盘容量超过2T的话,就使用Parted工具来实现对GPT磁盘进行分区操作。

  GPT格式的磁盘相当于原来MBR磁盘中原来保留4个partition table的4*16个字节,只留第一个16个字节,类似于扩展分区,真正的partitiontable在512字节之后,GPT磁盘没有四个主分区的限制。

下面是实际演练,分别使用fdisk与parted对不同容量硬盘进行分区。

二、fdisk分区(2T容量以下硬盘使用)

1、查看当前磁盘情况

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             133G   31G   96G  25% /
tmpfs                  16G  9.9G  5.9G  63% /dev/shm
/dev/sda1             504M   43M  436M   9% /boot
/dev/sda5             2.7T  2.4T  204G  93% /data
/dev/sdb1             2.7T  2.4T  204G  93% /data
[root@bidw tmp]# fdisk -l
 
Disk /dev/sda: 299.4 GB, 299439751168 bytes
255 heads, 63 sectors/track, 36404 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: 0x000ccf41
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          66      524288   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              66        1371    10485760   82  Linux swap / Solaris
/dev/sda3            1371       18888   140704768   83  Linux
/dev/sda4           18888       36405   140705792    5  Extended
/dev/sda5           18888       36405   140704768   83  Linux
 
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
 
 
Disk /dev/sdb: 2999.0 GB, 2998960914432 bytes
255 heads, 63 sectors/track, 364602 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
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      267350  2147483647+  ee  GPT
 
Disk /dev/sdc: 1999.8 GB, 1999844147200 bytes
81 heads, 63 sectors/track, 765421 cylinders
Units = cylinders of 5103 * 512 = 2612736 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x42d69282

可以看到/dev/sdc是需要分区的

2、使用fdisk进行分区

[root@bidw tmp]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xc1b09294.
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): 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
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-243133, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-243133, default 243133): 
Using default value 243133
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
 
WARNING: Re-reading the partition table failed with error 22: Invalid argument.
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.

3、格式化为ext4系统

[root@bidw tmp]# mkfs.ext4 /dev/sdc1
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
122060800 inodes, 488242944 blocks
24412147 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
14900 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, 20480000, 23887872, 71663616, 78675968, 
    102400000, 214990848
 
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

然后查看磁盘情况

[root@bidw tmp]# fdisk -l
 
Disk /dev/sda: 299.4 GB, 299439751168 bytes
255 heads, 63 sectors/track, 36404 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: 0x000ccf41
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          66      524288   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              66        1371    10485760   82  Linux swap / Solaris
/dev/sda3            1371       18888   140704768   83  Linux
/dev/sda4           18888       36405   140705792    5  Extended
/dev/sda5           18888       36405   140704768   83  Linux
 
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
 
 
Disk /dev/sdb: 2999.0 GB, 2998960914432 bytes
255 heads, 63 sectors/track, 364602 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
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      267350  2147483647+  ee  GPT
 
Disk /dev/sdc: 1999.8 GB, 1999844147200 bytes
81 heads, 63 sectors/track, 765421 cylinders
Units = cylinders of 5103 * 512 = 2612736 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x42d69282
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1      765634  1953513560   83  Linux

可以看到/dev/sdc1已经格式化完成

4、挂载

[root@bidw tmp]# mount /dev/sdc1 /u01
[root@bidw tmp]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             133G   32G   95G  25% /
tmpfs                  16G  9.9G  5.9G  63% /dev/shm
/dev/sda1             504M   43M  436M   9% /boot
/dev/sda5             2.7T  2.4T  204G  93% /data
/dev/sdb1             2.7T  2.4T  204G  93% /data
/dev/sdc1             1.8T  196M  1.7T   1% /u01

可以看到/dev/sdc1已经挂载到/u01目录

5、把挂载信息放入fstab里

[root@bidw tmp]# cat /etc/fstab 
"/etc/fstab" 19L, 979C#
# /etc/fstab
# Created by anaconda on Sat Dec 29 12:06:41 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=bcc682b0-5a55-4df8-8f7f-2ebfca7e0bf9 / ext4    defaults 1 1
UUID=f75b95fb-78cf-4070-b629-a5b1983edc83 /boot ext4    defaults 1 2
UUID=5743454b-f226-4c7c-8ad4-bf8db690572b /data xfs     defaults 1 2
UUID=e9ea4e7a-d959-4c63-a562-dc059d58ac08 swap swap    defaults 0 0
tmpfs /dev/shm tmpfs   defaults,size=16G 0 0
devpts /dev/pts devpts  gid=5,mode=620  0 0
sysfs /sys sysfs   defaults 0 0
proc /proc proc    defaults 0 0
 
/dev/sdb1 /data ext3       defaults  0   0

然后对最新的配置生效一下

[root@bidw tmp]# mount -a
[root@bidw tmp]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,size=16G)
/dev/sda1 on /boot type ext4 (rw)
/dev/sda5 on /data type xfs (rw)
/dev/sdb1 on /data type ext3 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /sys/kernel/config type configfs (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/sdc1 on /u01 type ext4 (rw)

6、测试一下新分区对象

[root@bidw tmp]# cd /u01
[root@bidw u01]# ll
total 16
drwx------ 2 root root 16384 Jul 21 09:49 lost+found
[root@bidw u01]# touch test
[root@bidw u01]# ll
total 16
drwx------ 2 root root 16384 Jul 21 09:49 lost+found
-rw-r--r-- 1 root root     0 Jul 21 10:03 test
[root@bidw u01]# rm test
rm: remove regular empty file `test'? y

三、parted分区(2T容量以上硬盘使用)

1、查看分区情况

root@ip-10-10-27-116:/home
02:36:30 # fdisk -l
 
Disk /dev/sda: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 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: 0x00045789
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         131     1048576   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             131        4309    33554432   82  Linux swap / Solaris
/dev/sda3            4309      121535   941620224   83  Linux
 
Disk /dev/sdb: 2999.0 GB, 2998960914432 bytes
255 heads, 63 sectors/track, 364602 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

可以看到/dev/sdb是需要分区的,磁盘容量为3t,fdisk没办法分区,只能使用parted进行gpt分区了

下面是当前已经在用的磁盘情况

root@ip-10-10-27-116:/home
02:38:04 # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             884G  2.0G  838G   1% /
tmpfs                  32G     0   32G   0% /dev/shm
/dev/sda1            1008M   56M  902M   6% /boot
2、使用parted进行分区
root@ip-10-10-27-116:/home
02:38:06 # parted /dev/sdb
GNU Parted 2.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Error: /dev/sdb: unrecognised disk label                                  
(parted) mklabel gpt                                                      
(parted) mkpart primary 0% 100%                                           
(parted) print                                                            
Model: DELL PERC H710P (scsi)
Disk /dev/sdb: 2999GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
 
Number  Start   End     Size    File system  Name     Flags
 1      1049kB  2999GB  2999GB               primary
 
(parted) quit                                                             
Information: You may need to update /etc/fstab.
介绍一下各个命令的意思
p 
是打印磁盘信息,查看分区的情况,找到起始和结束位置。
mklabel gpt
是进行gpt类型分区
mkpart primary 0% 100%
是primary指分区类型为主分区,0是分区开始位置,100%是分区结束位置。相同的命令为:mkpart primary 0-1 或者是:mkpart  primary 0  XXXXXX结束的空间
print
打印当前分区,查看分区设置是否正确
quit
退出

查看磁盘分区情况

02:44:07 # fdisk -l
 
Disk /dev/sda: 999.7 GB, 999653638144 bytes
255 heads, 63 sectors/track, 121534 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: 0x00045789
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1         131     1048576   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2             131        4309    33554432   82  Linux swap / Solaris
/dev/sda3            4309      121535   941620224   83  Linux
 
WARNING: GPT (GUID Partition Table) detected on '/dev/sdb'! The util fdisk doesn't support GPT. Use GNU Parted.
 
 
Disk /dev/sdb: 2999.0 GB, 2998960914432 bytes
255 heads, 63 sectors/track, 364602 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
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1      267350  2147483647+  ee  GPT

可用看到/dev/sdb1已经进行了gpt类型分区

3、格式化为ext4系统

02:44:12 # mkfs.ext4 /dev/sdb1
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
183042048 inodes, 732167680 blocks
36608384 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
22344 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, 20480000, 23887872, 71663616, 78675968, 
    102400000, 214990848, 512000000, 550731776, 644972544
 
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
 
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
root@ip-10-10-27-116:/home
02:47:23 # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             884G  2.0G  838G   1% /
tmpfs                  32G     0   32G   0% /dev/shm
/dev/sda1            1008M   56M  902M   6% /boot

4、挂载

创建挂载目录data

oot@ip-10-10-27-116:/home
02:49:38 # mkdir /data
然后挂载/dev/sdb1到/data目录
root@ip-10-10-27-116:/home
02:50:36 # mount /dev/sdb1 /data
root@ip-10-10-27-116:/home
02:50:41 # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             884G  2.0G  838G   1% /
tmpfs                  32G     0   32G   0% /dev/shm
/dev/sda1            1008M   56M  902M   6% /boot
/dev/sdb1             2.7T  201M  2.6T   1% /data

5、加入fstab

root@ip-10-10-27-116:/home
02:51:39 # cat /etc/fstab 
 
#
# /etc/fstab
# Created by anaconda on Wed Aug 27 13:39:16 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=1bc74b58-1fbe-4f65-9790-d02abc23d461 /                       ext4    defaults        1 1
UUID=ebbbaa89-e509-4fef-8763-be6eed9408c7 /boot                   ext4    defaults        1 2
UUID=98417724-a1c5-4f9a-9750-85beda11e4e1 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/sdb1               /data                   ext4    defaults        0 0

生效一下

02:51:43 # mount -a
root@ip-10-10-27-116:/home
02:51:45 # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda3             884G  2.0G  838G   1% /
tmpfs                  32G     0   32G   0% /dev/shm
/dev/sda1            1008M   56M  902M   6% /boot
/dev/sdb1             2.7T  201M  2.6T   1% /data

6、测试

11:04:13 # cd /data
root@ip-10-10-27-116:/data
11:06:44 # echo "this is test">test
root@ip-10-10-27-116:/data
11:06:52 # cat test
this is test
root@ip-10-10-27-116:/data
11:06:54 # rm test
rm: remove regular file `test'? y
root@ip-10-10-27-116:/data