7

Anyone can provide me any test case for the below command: blockdev --setbsz BYTES to set/change the block size.

I have tried like below but no luck.

$ blockdev --setbsz 2048 /dev/sda5
blockdev: 2048: No such file or directory
15
  • Can you tell us what you're actually trying to do? Have you read the documentation?
    – HalosGhost
    Jul 18, 2014 at 8:11
  • I tried to use --setbsz option for blockdev; but giving the above error. What will be the correct syntax for this option? Jul 18, 2014 at 8:13
  • Read man blockdev.
    – HalosGhost
    Jul 18, 2014 at 8:17
  • 1
    @HalosGhost man blockdev doesn't help him/her. According to the man page this command is correct.
    – polym
    Jul 18, 2014 at 8:19
  • 2
    from man: Note that the block size is specific to the current file descriptor opening the block device, so the change of block size only persists for as long as blockdev has the device open, and is lost once blockdev exits.
    – Dani_l
    Jul 18, 2014 at 8:47

3 Answers 3

6

Check the block size of current device.

$ blockdev --getbsz /dev/vdb1
512

Unmount filesystem to change block size.

$ umount /dev/vdb1

Create filesystem to change new block size.

$ mkfs -t ext4 -b 4096 /dev/vdb1

Mount to check the changed block size.

$ mount /dev/vdb1 /test/
$ blockdev --getbsz /dev/vdb1
4096
1

You have to do it as root user after unmounting that device.

# this is as root user
[root@pse-linvm ~]# blockdev --setbsz 4096 /dev/vda2
BLKBSZSET: Device or resource busy
[root@pse-linvm ~]# blockdev --setbsz 4096 /dev/vda6
/dev/vda6: No such file or directory

# this is normal user
[root@pse-linvm ~]# su - raja
[raja@pse-linvm ~]$ blockdev --getbsz /dev/vda2
/dev/vda2: Permission denied

# Error same as yours
[raja@pse-linvm ~]$ blockdev --getbsz 4096 /dev/vda2
4096: No such file or directory
4
  • If that is the problem, then the dev's of blockdev should fix their error messages.
    – polym
    Jul 18, 2014 at 8:23
  • you get the error on GET, @samir pradhan got it on SET.
    – Dani_l
    Jul 18, 2014 at 8:23
  • @Dani_l I have shown the error bro. check once with my proposal & tell me if I am wrong.
    – rɑːdʒɑ
    Jul 18, 2014 at 8:27
  • I tried it but it doesn't change the value....see the test cases i posted above Jul 18, 2014 at 8:29
1

Not an answer - just posting in answer box for clarity

[dani@localhost ~]$ blockdev --getbsz /dev/sda1 
blockdev: cannot open /dev/sda1: Permission denied
[dani@localhost ~]$ 
[dani@localhost ~]$ su -
Password: 
[root@localhost ~]# blockdev --getbsz /dev/sda1 
1024
[root@localhost ~]# blockdev --setbsz 1024 /dev/sda1 
BLKBSZSET: Device or resource busy
[root@localhost ~]# umount /boot 
[root@localhost ~]# blockdev --setbsz 1024 /dev/sda1 

works well on fd20 with linux-utils 2.24.2

2
  • $ mount /dev/sda1 on / type ext3 (rw,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) none on /sys type sysfs (rw,noexec,nosuid,nodev) ...binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev) $ sudo blockdev --getbsz /dev/sda1 4096 $ sudo blockdev --getbsz /dev/sdb1 512 $ sudo blockdev --setbsz 2048 /dev/sdb1 $ sudo blockdev --getbsz /dev/sdb1 512 Here i mount and tried to change the bsz but no change. And i didn't get any error. Jul 18, 2014 at 8:47
  • answered in comments to your OP
    – Dani_l
    Jul 18, 2014 at 8:50

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.