Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: hiding partitions in Grub 2

  1. #11
    Join Date
    Apr 2006
    Location
    Galax,Va. USA
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: hiding partitions in Grub 2

    That's what I'm thinking. I'm not sure what it could be tho. Anyway I'm going to install Grub2 1.97 final tonight and then see if it takes care of the problem. I had to reinstall grub after a grandson problem also so that may have disturbed something.
    Iguana

    Registered Linux User #490719

  2. #12
    Join Date
    Jun 2009
    Location
    SW Forida
    Beans
    Hidden!
    Distro
    Kubuntu

    Re: hiding partitions in Grub 2

    dgp77 - you can move the entries from grub.cfg to /etc/grub.d/40_custom. If you turn off the executable flag on osprober then when you run update-grub2 only your manual entries will be added.
    Just remember to turn it on again if you ever want it to probe for other new operating systems automatically.

    edit - the correct way to turn osprober off is in /etc/default/grub
    GRUB_DISABLE_OS_PROBER=true
    Last edited by oldfred; November 10th, 2009 at 05:46 PM. Reason: correction
    UEFI boot install & repair info - Regularly Updated :
    https://ubuntuforums.org/showthread.php?t=2147295
    Please use Thread Tools above first post to change to [Solved] when/if answered completely.

  3. #13
    Join Date
    Jul 2010
    Beans
    10
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: hiding partitions in Grub 2

    After long time of struggling with various boot loaders and their configurations, mainly because there are almost NO informations about GRUB 2 and hidding partitions when you have TWO or more hard disks, finally today I managed to configure GRUB 2 to work as I wish. So, to maybe save someone's time, I'll write my example here.

    I got two 250GB SATA HDDs, sda and sdb.
    SDA is partitioned on this way:
    sda1 - primary - 25GB - NTFS - [with XP64bit]
    sda2- primary - 100GB - NTFS - [ Steam is here ]
    sda3 - extended to/on logical partitions:
    sda5 - SWAP - 4.2GB
    sda6 - Ubuntu Natty (last usable Ubuntu linux) - 12GB - EXT3
    sda7 - Empty, awaiting Xubuntu 12.04LTS - 12GB - EXT3
    sda8 - Big Linux Partition, (NOT /home), For various Linux files, backups, ..

    Installation was going on this order:
    (Hard Disk 1, sda, connected at motherboard's IDE 1 connector).
    XP was installed first, then was Ubuntu Natty, with GRUB 2 placed on MBR .
    (Second disk, SDB was disconnected from motherboard IDE 2 connector.)
    DVD-rom is connected at motherboard's IDE 4 connector.

    After that, I disconnected SDA from motherboard, and connected SDB to IDE 2 connector/slot.
    Reason for this is exactly the same I started to search and learn "How to hide/unhide partitions with GRUB 2", and that is:
    I don't want XP see Win 7 boot and cfg files (and root partition) and vice-versa.

    Then I installed Windows 7 x64, allowing that it takes entire disk.

    Allowing Windows 7 to take entire EMPTY hard disk, produce that win 7 will create special "System reserved" partition.

    If you have a pre-configured, or better to say pre-partitioned HDD, let's say one 50GB partition for OS Win 7, and rest (in this case) 200GB for files (Steam ;
    windows 7 will not create that "System reserved" partition (100MB) {this is just an info from my experience}.

    So, after Win 7 installation there was one "System reserved" 100MB partition, and rest is one C:/ partition 250GB (of course it is not 250, it's less, but this is only for purpose of this writting).
    After defragmentation (defragmenting NTFS partition before resizing is important), I shrinked it to 35GB that is C:\, and rest was formated as NTFS, which becomes E:\ (cca a little more than 200GB) {note: D:\ is DVD-rom, if for any reason you want, you can change that drive letters later in windows}
    If you are curious why I do partitioning on that way:
    I always do it that way, because then I can make backups of only OS partitions, so large program files/games will stay on E:, and backup with compression ratio 50% will result with acceptable backup size of 5 - 10GB, and that backup can be stored on that big NTFS partition; including Linux partition backups.

    Next, I connected both hard disk, checked if BIOS is configured to boot from SDA (bios will not say SDA or SDB, so you have to learn what are names of disks in boot order)
    Booting from SDA will display GRUB2 menu with Ubuntu and XP.
    Do NOT choose XP! Windows 7 partitions will not be hidden from it!
    Choose Ubuntu.

    After booting I'm going to configure grub2 files as I need.
    Note: I'm logged as root, so I will not use sudo command.
    First, in terminal:
    Code:
    root@MSI:~# update-grub
    Generating grub.cfg ...
    Found linux image: /boot/vmlinuz-2.6.38-13-generic
    Found initrd image: /boot/initrd.img-2.6.38-13-generic
    Found linux image: /boot/vmlinuz-2.6.38-8-generic
    Found initrd image: /boot/initrd.img-2.6.38-8-generic
    Found Windows NT/2000/XP on /dev/sda1
    Found Windows 7 (loader) on /dev/sdb1
    done
    root@MSI:~#
    Note that now Windows 7 OS is just added to GRUB 2 boot menu, NOTHING is hidden yet.
    Also, the /etc/grub.d/20_memtest86+ is set to be non-executable, so that is the reason why there is no memtest in grub2 menu entry.

    Then, edit file /etc/grub.d/40_custom with text editor.
    In my example, it is this:
    Code:
    #!/bin/sh
    exec tail -n +3 $0
    # This file provides an easy way to add custom menu entries.  Simply type the
    # menu entries you want to add after this comment.  Be careful not to change
    # the 'exec tail' line above.
    menuentry "XP 64 (with hidden W7)" {
    insmod ntfs
    set root=(hd0,1)
    parttool (hd0,1) hidden-
    parttool (hd1,1) hidden+
    parttool (hd1,2) hidden+
    chainloader +1
    parttool ${root} boot+
    boot
    }
    menuentry "Win 7 (with hidden XP 64)" {
    insmod ntfs
    set root=(hd1,1)
    parttool (hd1,1) hidden-
    parttool (hd1,2) hidden-
    parttool (hd0,1) hidden+
    chainloader +1
    parttool ${root} boot+
    boot
    }
    # END #
    Save file and then run "update-grub" again.

    You will see EXACTLY the same output as it was before:
    Code:
    root@MSI:~# update-grub
    Generating grub.cfg ...
    Found linux image: /boot/vmlinuz-2.6.38-13-generic
    Found initrd image: /boot/initrd.img-2.6.38-13-generic
    Found linux image: /boot/vmlinuz-2.6.38-8-generic
    Found initrd image: /boot/initrd.img-2.6.38-8-generic
    Found Windows NT/2000/XP on /dev/sda1
    Found Windows 7 (loader) on /dev/sdb1
    done
    root@MSI:~#
    In other words, there you will NOT see your new added menu entryes.
    BUT, if you reboot now your computer, there WILL BE new menu entryes, just as I named them:

    Ubuntu, with Linux 2.6.38-13-generic
    Ubuntu, with Linux 2.6.38-13-generic (recovery mode)
    Windows NT/2000/XP on /dev/sda1
    Windows 7 (loader) on /dev/sdb1
    XP 64 (with hidden W7)
    Win 7 (with hidden XP 64)

    SO, do not choose any of listed entryes:
    Windows NT/2000/XP on /dev/sda1 or Windows 7 (loader) on /dev/sdb1
    cause, they will boot choosen system without any hideden partitions; instead, choose
    XP 64 (with hidden W7) or Win 7 (with hidden XP 64)

    Note: "XP 64 (with hidden W7)" or "Win 7 (with hidden XP 64)" are only the OS menu entry names that I set for them, you can set names in that file "40_custom" as you wish.

    Having grub 2 configuration like this, when I boot to XP, I can't see Windows 7 "system reserved" partition, nor Windows 7 C:\ partition, BUT I CAN see Windows 7 E:\ partition where are valuable files created, downloaded or stored when I was in Windows 7;
    When booted ino Win 7, it can't see XP's C:\ partition, but it can see E:\ partition.
    Of course those "E:\" partitions, if for some reason needed, can also be configured to be hidden.

    As you can see from my mentioning Steam, only reason why I still have windows is for gaming.

    I hope this will help someone.

    BTW, here is grub.cfg file:
    Code:
    #
    # DO NOT EDIT THIS FILE
    #
    # It is automatically generated by grub-mkconfig using templates
    # from /etc/grub.d and settings from /etc/default/grub
    #
    
    ### BEGIN /etc/grub.d/00_header ###
    if [ -s $prefix/grubenv ]; then
      set have_grubenv=true
      load_env
    fi
    set default="0"
    if [ "${prev_saved_entry}" ]; then
      set saved_entry="${prev_saved_entry}"
      save_env saved_entry
      set prev_saved_entry=
      save_env prev_saved_entry
      set boot_once=true
    fi
    
    function savedefault {
      if [ -z "${boot_once}" ]; then
        saved_entry="${chosen}"
        save_env saved_entry
      fi
    }
    
    function recordfail {
      set recordfail=1
      if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
    }
    
    function load_video {
      insmod vbe
      insmod vga
      insmod video_bochs
      insmod video_cirrus
    }
    
    insmod part_msdos
    insmod ext2
    set root='(/dev/sda,msdos6)'
    search --no-floppy --fs-uuid --set=root fa90a1fd-6c68-402f-75cf-04fdd5995493
    if loadfont /usr/share/grub/unicode.pf2 ; then
      set gfxmode=auto
      load_video
      insmod gfxterm
    fi
    terminal_output gfxterm
    insmod part_msdos
    insmod ext2
    set root='(/dev/sda,msdos6)'
    search --no-floppy --fs-uuid --set=root fa90a1fd-6c68-402f-75cf-04fdd5995493
    set locale_dir=($root)/boot/grub/locale
    set lang=en_US
    insmod gettext
    if [ "${recordfail}" = 1 ]; then
      set timeout=-1
    else
      set timeout=10
    fi
    ### END /etc/grub.d/00_header ###
    
    ### BEGIN /etc/grub.d/05_debian_theme ###
    set menu_color_normal=white/black
    set menu_color_highlight=black/light-gray
    if background_color 44,0,30; then
      clear
    fi
    ### END /etc/grub.d/05_debian_theme ###
    
    ### BEGIN /etc/grub.d/10_linux ###
    if [ ${recordfail} != 1 ]; then
      if [ -e ${prefix}/gfxblacklist.txt ]; then
        if hwmatch ${prefix}/gfxblacklist.txt 3; then
          if [ ${match} = 0 ]; then
            set linux_gfx_mode=keep
          else
            set linux_gfx_mode=text
          fi
        else
          set linux_gfx_mode=text
        fi
      else
        set linux_gfx_mode=keep
      fi
    else
      set linux_gfx_mode=text
    fi
    export linux_gfx_mode
    if [ "$linux_gfx_mode" != "text" ]; then load_video; fi
    menuentry 'Ubuntu, with Linux 2.6.38-13-generic' --class ubuntu --class gnu-linux --class gnu --class os {
    	recordfail
    	set gfxpayload=$linux_gfx_mode
    	insmod part_msdos
    	insmod ext2
    	set root='(/dev/sda,msdos6)'
    	search --no-floppy --fs-uuid --set=root fa90a1fd-6c68-402f-75cf-04fdd5995493
    	linux	/boot/vmlinuz-2.6.38-13-generic root=UUID=fa90a1fd-6c68-402f-75cf-04fdd5995493 ro   quiet splash vt.handoff=7
    	initrd	/boot/initrd.img-2.6.38-13-generic
    }
    menuentry 'Ubuntu, with Linux 2.6.38-13-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
    	recordfail
    	set gfxpayload=$linux_gfx_mode
    	insmod part_msdos
    	insmod ext2
    	set root='(/dev/sda,msdos6)'
    	search --no-floppy --fs-uuid --set=root fa90a1fd-6c68-402f-75cf-04fdd5995493
    	echo	'Loading Linux 2.6.38-13-generic ...'
    	linux	/boot/vmlinuz-2.6.38-13-generic root=UUID=fa90a1fd-6c68-402f-75cf-04fdd5995493 ro single 
    	echo	'Loading initial ramdisk ...'
    	initrd	/boot/initrd.img-2.6.38-13-generic
    }
    submenu "Previous Linux versions" {
    menuentry 'Ubuntu, with Linux 2.6.38-8-generic' --class ubuntu --class gnu-linux --class gnu --class os {
    	recordfail
    	set gfxpayload=$linux_gfx_mode
    	insmod part_msdos
    	insmod ext2entryies
    	set root='(/dev/sda,msdos6)'
    	search --no-floppy --fs-uuid --set=root fa90a1fd-6c68-402f-75cf-04fdd5995493
    	linux	/boot/vmlinuz-2.6.38-8-generic root=UUID=fa90a1fd-6c68-402f-75cf-04fdd5995493 ro   quiet splash vt.handoff=7
    	initrd	/boot/initrd.img-2.6.38-8-generic
    }
    menuentry 'Ubuntu, with Linux 2.6.38-8-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
    	recordfail
    	set gfxpayload=$linux_gfx_mode
    	insmod part_msdos
    	insmod ext2
    	set root='(/dev/sda,msdos6)'
    	search --no-floppy --fs-uuid --set=root fa90a1fd-6c68-402f-75cf-04fdd5995493
    	echo	'Loading Linux 2.6.38-8-generic ...'
    	linux	/boot/vmlinuz-2.6.38-8-generic root=UUID=fa90a1fd-6c68-402f-75cf-04fdd5995493 ro single 
    	echo	'Loading initial ramdisk ...'
    	initrd	/boot/initrd.img-2.6.38-8-generic
    }
    }
    ### END /etc/grub.d/10_linux ###
    
    ### BEGIN /etc/grub.d/20_linux_xen ###
    ### END /etc/grub.d/20_linux_xen ###
    
    ### BEGIN /etc/grub.d/30_os-prober ###
    menuentry "Windows NT/2000/XP (on /dev/sda1)" --class windows --class os {
    	insmod part_msdos
    	insmod ntfs
    	set root='(/dev/sda,msdos1)'
    	search --no-floppy --fs-uuid --set=root 641088131087E9FE
    	drivemap -s (hd0) ${root}
    	chainloader +1
    }
    menuentry "Windows 7 (loader) (on /dev/sdb1)" --class windows --class os {
    	insmod part_msdos
    	insmod ntfs
    	set root='(/dev/sdb,msdos1)'
    	search --no-floppy --fs-uuid --set=root 5C029AB7029A961C
    	chainloader +1
    }
    ### END /etc/grub.d/30_os-prober ###
    
    ### BEGIN /etc/grub.d/40_custom ###
    # This file provides an easy way to add custom menu entries.  Simply type the
    # menu entries you want to add after this comment.  Be careful not to change
    # the 'exec tail' line above.
    menuentry "XP 64 (with hidden W7)" {
    insmod ntfs
    set root=(hd0,1)
    parttool (hd0,1) hidden-
    parttool (hd1,1) hidden+
    parttool (hd1,2) hidden+
    chainloader +1
    parttool ${root} boot+
    boot
    }
    menuentry "Win 7 (with hidden XP 64)" {
    insmod ntfs
    set root=(hd1,1)
    parttool (hd1,1) hidden-
    parttool (hd1,2) hidden-
    parttool (hd0,1) hidden+
    chainloader +1
    parttool ${root} boot+
    boot
    }
    # END #
    ### END /etc/grub.d/40_custom ###
    
    ### BEGIN /etc/grub.d/41_custom ###
    if [ -f  $prefix/custom.cfg ]; then
      source $prefix/custom.cfg;
    fi
    ### END /etc/grub.d/41_custom ###
    0

  4. #14
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

    Re: hiding partitions in Grub 2

    Closed, necromancy.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •