3

I performed the following procedure in order to add 400m to swap,

I took the 400m from the sdb disk for the swap increasing

Everything was ok but before the last command , I performed

mkswap /dev/rootvg/swap

And I get the following warning messages from mkswap

mkswap: /dev/rootvg/swap: warning: don't erase bootbits sectors
    on whole disk. Use -f to force.
Setting up swapspace version 1, size = 2490364 KiB
no label, UUID=2f42fa37-987d-40a5-8cf6-5707e1d8f077

Finally swap was extend to 2.4G as expected

But I little worry about the warning message from mkswap command

Please advise what is meaning of the warning:

mkswap: /dev/rootvg/swap: warning: don't erase bootbits sectors
on whole disk. Use -f to force.

And if this is OK?

My procedure on the linux redhat machine - version 6

# swapon -s
Filename                                Type            Size    Used      Priority
/dev/dm-1                               partition       2064380 0       -1

# free
        total       used       free     shared    buffers     cached
Mem:       5991892     539036    5452856        212      70444     270664
-/+ buffers/cache:     197928    5793964
 Swap:      2064380          0    2064380


# pvs
PV         VG      Fmt  Attr PSize  PFree
 /dev/sdb   rootvg  lvm2 a--u  7.97g 416.00m
 /dev/sdc   orahome lvm2 a--u 30.00g  15.00g

# lsblk /dev/sdb
NAME                  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdb                     8:16   0    8G  0 disk
|-rootvg-swap (dm-1)  253:1    0    2G  0 lvm  [SWAP]
|-rootvg-slash (dm-2) 253:2    0  576M  0 lvm  /
|-rootvg-usr (dm-3)   253:3    0  1.4G  0 lvm  /usr
|-rootvg-home (dm-4)  253:4    0  256M  0 lvm  /home
|-rootvg-opt (dm-5)   253:5    0  416M  0 lvm  /opt
`-rootvg-var (dm-6)   253:6    0    3G  0 lvm  /var

# swapon -s
Filename                                Type            Size    Used     Priority
/dev/dm-1                               partition       2064380 0       -1

# swapoff /dev/rootvg/swap

# lvresize /dev/rootvg/swap -L +400m
 Rounding size to boundary between physical extents: 416.00 MiB.
 Size of logical volume rootvg/swap changed from 1.97 GiB (63 extents) to  2.38 GiB (76 extents).
 Logical volume swap successfully resized.

# mkswap /dev/rootvg/swap
mkswap: /dev/rootvg/swap: warning: don't erase bootbits sectors
    on whole disk. Use -f to force.
Setting up swapspace version 1, size = 2490364 KiB
no label, UUID=2f42fa37-987d-40a5-8cf6-5707e1d8f077

# swapon /dev/rootvg/swap

# free
         total       used       free     shared    buffers     cached
 Mem:       5991892     539680    5452212        212      70536     270892
 -/+ buffers/cache:     198252    5793640
 Swap:      2490364          0    2490364
5

Looks like a safety precaution to prevent you from destroying a boot sector, etc... when using a whole disk when you may have meant to use a partition.

This warning message not longer present in CentOS 6.5 nor Ubuntu 16.04.

This older (2006) mkswap.c defines bootbits vaguely: http://code.metager.de/source/xref/busybox/util-linux/mkswap.c

/*  char     bootbits[1024];    Space for disklabel etc. */

From the CentOS 6.5 mkswap.c:

        if (is_whole_disk_fd(fd, devname)) {
                /* don't zap bootbits on whole disk -- we know nothing
                 * about bootloaders on the device */
                whole = 1;
                zap = 0;

I'm not amazing with C, but the new code appears more intelligent and perhaps preserves boot data. I'm not delving that far.

  • by the way I this machine is Red Hat Enterprise Linux Server release 6.8 (Santiago) – King David Sep 15 '16 at 12:56
  • so the button line is not use the -f option , ? , – King David Sep 15 '16 at 12:59
  • @Jogeff I downloaded the code for Centos 6.5 util-linux-ng-2.17.2 and that error message is not in the code. Perhaps RHEL is different, or the newer one is... I did the same for Ubuntu 16.04. – Ryan Babchishin Sep 15 '16 at 13:00
  • @Jogeff There's nothing wrong with zapping (as the code calls it) an LVM volume you created for swap as far as I'm concerned, unless you boot off it? Using -f is fine. – Ryan Babchishin Sep 15 '16 at 13:02
  • 1
    @Jogeff What are you concerned about? I answered your question in detail. – Ryan Babchishin Sep 15 '16 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.