| Translate 
 
   
 
 
   
 
   
 
   
 
   
 
   
 
   
 
   
 
   
 
   
 
   
IBU 
Consol
 |  | Shrinking MS Win-7 & 4 x NTFS To Make Space To Install
    BSDBy Julian H. Stacey November 2011 -
    January 2012.Index
      This page is a guide for experienced BSD people to shrink
      PCs that are fully populated with 4 x MS + NTFS.
     
      Imagine you acquire a new laptop/ notebook, want to
      install a BSD partition, & rapidly curse ! - The whole
      thing is stuff full of damned Microsoft already ! All 4 Fdisk
      partitions occupied with NTFS, & no slice unallocated in
      Fdisk, & all sectors allocated to MS File Systems,No MS install/ backup media, (though it's a legal copy of
      MS with new PC hardware, (but amazingly that's how shops sell
      MS on PCs now!, no media except original hard disk !).You want to carefully resize MS file systems, & merge
      data from one or more to reduce number of file systems,
        You want to not damage the MS, to allow later 
        
          test of hardware driversto run MS apps under an emulation (eg virtualbox (or
          other)) under BSD to save rebootinginstall the MS + BSD to a replacement perhaps larger
          disk.You don't even have a CDROM drive ('cos it's a net book
      size device) - just USB & ethernet. (OK one could connect
      a USB external CDROM/DVD drive).You don't know MS, or how to back it up, or want to waste
      time learning MS backup programs.You don't trust MS or where it leaves its droppings (boot
      sectors, suspend tracks, anti copy stuff, etc.You do Not want to use resizer tools that run on MS,
      (some needing licenses, some needing virus checkers, You
      don't know where to get or trust tools for MS, & don't
      want to, (Well maybe cygnus might be an option).Don't trust what you don't personally have Source code
      for.Don't want to go playing disk jockey with Linux
      distributions to leverage resizer tools on those.You insist you will do the job exclusively with tools
      running on BSD only, self compiled from local sources on a
      spare local PC. ----
      This requirement is not well enough documented in the
      FreeBSD Handbook. & FreeBSD-8.2-RELEASE does Not come
      with a USB live image ready to handle this.I'm doing this the 100% pure BSD way, not taking any easy
      ways, 'cos I want to feed back to re@ for eg tools/ &/or
      to enhance the FreeBSD Live USB images.Later maybe I'll strip cruft, & feed back
      improvements for generic FreeBSD install images. So far it's
      partly a log of lessons learned.If you discover things I haven't, feed back to me &/or FreeBSD.Org
      please. 
      
      Post to HP forum Wed Jan 11 23:39:07 CET 2012 
2 or 3 Fdisk needed for other OSs on HP Pavilion dm3-1155ea
I need at least 2, pref. 3 Fdisk slices Unused, for other operating systems.
Need to compress Microsoft +HP into 1 (or max 2 Fdisk slices. How ?
Questions:
- What/Why are/do all 4 Fdisk partitions cluttering up HP Pavilion dm3-1155ea ?
- What is this annoyingly seperate 200 M F1 ?
- Why won't F2 boot direct ?
- How to merge the wasteful 200 Meg F1 with 223305 Meg F2 
- What path in F2 to copy F3 tree under, to release F3.
  What files in F2 to edit so MS will be happy with commands paths
  & libs for F3 stuff.
- (I assume F4 just MS+HP recovery stuff I can move myself with Unix tools)
- Why when I remove the HP drive to external SATA enclosure & set
  BIOS to boot external USB, does MS boot fail after a bit 
  (with no useful message I recall) ?
- If removing the 250G internal disk, & installing a Terabyte disk,
  & carefully copying the first F3 fdisk slice back, MS won't boot.
  Does Win 7 need to be cylinder aligned to boot ? (I recall different
  geometry on new disk)
More background per my
  http://www.berklix.com/~jhs/hardware/laptops/shrink/#problem
 
      ENHANCING LIVE BOOTABLE USB
      IMAGEFreeBSD-8.2-RELEASE-amd64-memstick.img
        Script: 
         
          This syntax is NOT exact, its been salvaged form notes in
          changed circumstance, so think before you type :-) 
 
#!/bin/sh
# 1st run on a support machine to create an enhanced stick
mkdir /mnt/generic /mnt/custom
cd /pub/FreeBSD/releases/amd64/ISO-IMAGES/8.2/
mdconfig -a -t vnode -f FreeBSD-8.2-RELEASE-amd64-memstick.img
cd /
mount -t ufs /dev/md0a /mnt/generic
# Later     umount /mnt/generic
# Later     mdconfig -d -u 0
echo insert a 2 or more gig stick
# Improvement possible later:
#   would be better to do all assembly of target UFS on a file on hard
#    disk, then when finished dd it to stick.
bsdlabel -B -w -r /dev/da0
# Not /dev/ad0s1a :
# FreeBSD-8.2 live stick is not yet good enough to run within
# an F1 partition, it has to be a raw BSD FS on the beginning of raw
# media (USB stick).
newfs /dev/da0a
mount /dev/da0a /mnt/specific
( cd /mnt/generic ; tar cf - . ) | ( cd /mnt/specific && tar xf - )
# There are various reason (paths failing, shared libs etc)
# Why we will need to install extra tools from stick to target PC,
# So now copy set of sources to stick.
chroot /mnt/specific
# Import some ports:
cd /usr/ports
BITS=
BITS="Mk"               # Needed
BITS="Templates"            # Don't know if needed
BITS="Tools"                # Needed
cd /usr/ports
PORTS=
PORTS="${PORTS} converters/libiconv"     # 4 libiconv.so.3
PORTS="${PORTS} devel/gmake"         # dependency
PORTS="${PORTS} devel/libtool"       # dependency
PORTS="${PORTS} devel/libublio"      # 4 ntfsresize
PORTS="${PORTS} devel/pkg-config"    # dependency
PORTS="${PORTS} sysutils/fusefs-kmod"    # 4 fuse.ko
PORTS="${PORTS} sysutils/fusefs-libs"    # dependency
PORTS="${PORTS} sysutils/fusefs-ntfs"    # 4 ntfs-3g
#   sysutils/fusefs-ntfs has some problem on target host with -lgcc_s
for i in ${PORTS}
    do
    ( cd /usr/ports/$i  ; make clean ; make extract )
    done
tar cf - $(BITS $(PORTS) | ( cd  /mnt/custom/usr/ports ; tar xf - )
# src/ also needed for one of the ports above.
mkdir /mnt/custom/usr/src
(cd /usr/src ; tar cf - . ) | ( cd  /mnt/custom/usr/src ; tar xf - )
mount -t devfs dev /mnt/custom/dev
echo "After chroot,  sh /stick_make"
chroot /mnt/custom
echo "Ensure everything built, ready to reinstall on target pc later."
for i in ${PORTS}
    do
    ( cd /usr/ports/$i  ; make reinstall )
    #       make install might be sufficient nut I want to be sure.
    done
mkdir -p /ext /lap/1 /lap/2 /lap/3 /lap/4 /ext
ln -s /dist/usr/ports   /usr/ports
ln -s /dist/usr/src /usr/src
ln -s /dist/usr/obj /usr/obj
ln -s /dist/usr/local   /usr/local  # bin lib
ln -s /dist/usr/share/mk /usr/share/mk  # 4 sys.mk 4 make
ln -s /dist/usr/bin /usr/bin    # 4 uname
ln -s /dist/usr/sbin    /usr/sbin
# For /sbin/sysctl
cd /dist/sbin
for i in [a-z]*     # Not '*' cos don't want to fail to expand '['.
    do
    ( ln -s /dist/sbin/$i /sbin/$i )
    done
    # It will complain about files already there like /sbin/camcontrol
cd /dist/bin
for i in [a-z]*     # 4 /bin/mkdir
    do
    ( ln -s /dist/bin/$i /bin/$i )
    done
cd /etc
mv group group.was
ln -s /dist/etc/group /etc/group
ln -s /dist/usr/libexec /usr/libexec    # for cc1
ln -s /dist/usr/include /usr/include
ln -s /dist/usr/lib /usr/lib    # 4 crt1.o 4 fusefs-ntfs
# cd /usr/ports/sysutils/fusefs-ntfs ; make reinstall
#   /usr/bin/ld: cannot find -lgcc_s
# ldconfig -R does not solve it
#   cd /dist/usr/lib ; ls -l libgcc_s.so.1
#       libgcc_s.so.1 -> /lib/libgcc_s.so.1
# (Import same PORTS from above)
for i in ${PORTS}
    do
    echo Starting $i
    ( cd /usr/ports/$i  ; make FORCE_PKG_REGISTER=YES reinstall )
    # -i    does not overcome /dist being mounted read only.
    # reinstall not install as make install ran on other host
    # FORCE_PKG_REGISTER=YES in case running a 2nd time
    echo Finished $i
    echo
    done
ntfs-3g from /usr/ports/sysutils/fusefs-ntfs does allow writes to
FS, But the executable is not made static even with
    make.conf "CFLAGS += -static" Why ?
Solution:
build fusefs-ntfs & all other tools needed on to USB live stick
from FreeBSD-8.2-RELEASE-amd64-memstick.img
then extend that stick, then boot stick & install all extra tools on to
target pc ram disk & run from there. (hoping space enough)
PATH=${PATH}:/usr/local/bin
export PATH
kldload /dist/boot/kernel/ntfs.ko
kldload /dist/boot/kernel/ntfs_iconv.ko
kldload /dist/usr/local/modules/fuse.ko # avoids: failed to open fuse device
kldload /usr/local/modules/fuse.ko
# man kldxref
# kldxref /boot/kernel /boot/modules /dist/boot/kernel /dist/usr/local/modules
ldconfig -R /dist/usr/local/lib
    # 4 libfuse & libiconv.so.3 & as
    # file /usr/local/bin/ntfs-3g
    #   ELF 64-bit LSB executable, x86-64, version 1 (FreeBSD),
    #   dynamically linked (uses shared libs), for FreeBSD 8.2, stripped
        echo "fuse_load=YES" >> /boot/loader.conf 
         cp /usr/local/modules/fuse.ko /boot/kernel/ 
         # No symbolic link as not mounted early enough. No
        fuse.ko.symbols exists.
      
On target laptop, hit ESC or whatever to get into BIOS & set PC to bot from USB stick.
Boot the customised stick, then select
    Fixit   Repair mode with CDROM/DVD/floppy or start shell
    3=USB   Use the live filesystem from a USB drive
# Warning: Connect external disk after boot. else
# if both a real disk & a usb stick are both connected at boot time
# USB stick is da1 not da0.
mount -u -t ufs /dev/da0a /dist
mount -t devfs dev /dist/dev
chroot /dist
# Connect external USB disk.
fsck -y -t ufs /dev/da1a
mount -t ufs /dev/da1a /ext
# Hardware: HP Pavilion Entertainment PC (Notebook), Host name=laph
Boot MS, click "My Computer", See eg:
    C: Local    176    Gig Free of 218   Gig
    D: Recovery   2.39 Gig Free of  14.5 Gig
    E: HP_Tools  92    Gig Free of  99.1 Gig
Reboot,
Hold down Escape
Set bios to boot first off stick.
mount
ls /dist    # See content of USB stick
cd /dist/sbin
kldload /dist/boot/kernel/ntfs.ko
kldstat
mkdir /lap
cd /lap
mkdir 1 2 3 4
cd /
umount /dev/ad4s2
/dist/usr/local/sbin/ntfsresize -n -s 65G -v /dev/ad4s2
# If you see:
# /libexec/ld-elf.so.1: Shared object "libublio.so.1" not found
# On cross compile host:
    file /usr/local/sbin/ntfsresize
        /usr/local/sbin/ntfsresize: ELF 64-bit LSB executable,
        x86-64, version 1 (FreeBSD), dynamically linked
        (uses shared libs), for FreeBSD 8.2, stripped
    cd /usr/ports/sysutils/ntfsprogs
    unsetenv NOCLEANDEPENDS
    make clean
    grep -i static /etc/make.conf
        CFLAGS += -static
    make
    make install package
      ===>   ntfsprogs-2.0.0_1 depends on shared library: ublio.1 - found
    file /usr/local/sbin/ntfsresize
        /usr/local/sbin/ntfsresize: ELF 64-bit LSB executable,
        x86-64, version 1 (FreeBSD), dynamically linked
        (uses shared libs), for FreeBSD 8.2, stripped
    ls -l /usr/local/sbin/ntfsresize
        173376
    cd /usr/ports/devel/libublio
    make package
    cd /usr/ports/packages/All
    ls -l libublio-20070103.tbz ntfsprogs-2.0.0_1.tbz
 ( cd /host/fire/usra/ftp/pub/FreeBSD/ports/amd64/packages-8.2-release/All ; \
        tar cf - libublio-20070103.tbz  ntfsprogs-2.0.0_1.tbz ) | \
        ( cd /usb/sanblack.ufs && tar xf - )
/dist/usr/local/sbin/ntfsresize -n -s 65G -v /dev/ad4s2
/dist/usr/local/sbin/ntfsresize    -s 65G -v /dev/ad4s2
    adjusted bm_size: 1983648->1984000
halt
usb stick out
Win 7 boots
chkdsk runs automatically
------------
boot BSD
ntfsinfo -m /dev/ad4s2 | /dist/usr/bin/more
    sector size: 512
    cluster size 4096, volume size in clusters 15869139
/dist/sbin/fdisk -a /dev/ad4
    set to 2
    complains Class not found, but fdisk a 2nd time now shows 2
/dist/sbin/reboot
MS fails to boot
/dist/sbin/fdisk -a /dev/ad4
    set to 1
reboot
MS boots OK
So what IS this small F1 for, that F2 needs before booting ?
---------------
Backup data to external disk:
mkdir /ext
mount_ntfs /dev/da0s1 /ext
du /lap # 54 G
df  #   /ext has 67G Free
(cd /lap ; tar cf - . ) | ( cd /ext ; tar xf - )
mount_ntfs does not support mount writable, one can only read,
so I cant even read HP s3 to MS-Win s2 to free up an Fdisk partition to
install BSD into.
 
        Original Disk: 
         
          WD2500BEKT Scorpio Black , SATA 3 Gb/s, 250 G, 16M Cache,
          2.75 in./0.37 in., 69.85 mm/9.5 mm, 7200 RPM. 
           Swap file that varies in F2 (MS) that can be ignored
          by eg rdist6 backup: 
            -rwxrwxrwx 1 root wheel 4,022,325,248 Nov 15 15:24
            pagefile.sys
           Enormous recovery file in F3 (HP) in directory:
          /preload/
 
            -rwxr-xr-x 1 root bin 12,631,426,415 May 28 2010
            base.wim
          New Disk: 1 Terabyte 
ata2-master: pio=PIO4 wdma=WDMA2 udma=UDMA133 cable=40 wire
setting UDMA100
ad4: 953869MB <SAMSUNG HN-M101MBB 2AR10001> \
  at ata2-master UDMA100 SATA 3Gb/s
ad4: 1953525168 sectors [1938021C/16H/63S] \
  16 sectors/interrupt 1 depth queue
GEOM: new disk ad4
...
GEOM: ad4: partition 3 does not start on a track boundary.
GEOM: ad4: partition 3 does not end on a track boundary.
GEOM: ad4: partition 2 does not start on a track boundary.
GEOM: ad4: partition 2 does not end on a track boundary.
GEOM: ad4: partition 1 does not start on a track boundary.
GEOM: ad4: partition 1 does not end on a track boundary.
 
# In case Microsoft hides any boot &/or anti copy info on disk early sectors,
# grab raw images.
fdisk reported on 1st boot with BSD from USB stick:
Boot with USB Stick, FreeBSD-8.2; fdisk /dev/ad4
    Partition 1 Sysid 7,NTFS etc           199 M Active
            start      2048 size    407552
    Partition 2 Sysid 7,NTFS etc        223305 M
            start    409600 size 457328640
    Partition 3 Sysid=7,NTFS etc         14866 M
            start 457738240 size  30445568
    Partition 4 Sysid 12,DOS or Win-95 32 bit FAT (LBA) 103 M
            start 488183808 size    211312
Check numbers above with dc:
         2048
       407552 + p 409600
    457328640 + p 457738240
     30445568 + p 488183808
       211312 + p 488395120
Calculate beyond P4 to end of disk:
    dmesg | grep ad4 # 238475 MB WDC WD2500BEKT UDMA100 SATA 3Gb/s
        238475 not reported in blocks, try boot -v later
    dc    238475      2000   * p   476950000
    dc    238475     512 4 * * p   488396800
    dc 488396800 488395120   - p        1680 Spare blocks beyond P4
    Partition 1 start      2048 size    407552
    Partition 2 start    409600 size 457328640
    Partition 3 start 457738240 size  30445568
    Partition 4 start 488183808 size    211312
    Beyond P4   start 488395120  size     1680
After
    mount_ntfs    /dev/ad4s1 /lap/1 ; du -s -k /lap/1   #     25 M
    mount_ntfs    /dev/ad4s2 /lap/2 ; du -s -k /lap/2   # 48.098 M
    mount_ntfs    /dev/ad4s3 /lap/3 ; du -s -k /lap/3   # 12,641 M
    mount_msdosfs /dev/ad4s4 /lap/4 ; du -s -k /lap/4   #    6.7 M of 101 M
df
    ad4 1K-blocks       Used       Avail  Capacity # Content includes
    s1     203775      28815      174960  14%     # Boot
    s2  228664319   43896379   184767940  19%     # Windows
    s3   15222783   12708523     2514260  83%     # hp/
    s4     101562       6762       94800   7%     # $RECYCLE.BIN + Hewlett
    Analysis with dc shows P1,P2,P3 from fdisk entries each
    have 2x512 more than df shows as size, but with P4, The DOS
    FS shown by df within the fdisk slice is considerably
    smaller:
            Df -k        2xDf       Fdisk
           203775 2 * p    407550      407552
        228664319 2 * p 457328638   457328640
         15222783 2 * p  30445566    30445568
           101562 2 * p    203124      211312
Later df -b (based on mount from ntfs3g I think)
    Partition 1 fuse0    size    407544
    Partition 2 fuse1    size 126953112 # dc 126953112 512 * p 64999993344
    Partition 3 fuse2    size  30445560
    Partition 4      size    203124
These probably don't include some NTFS overhead blocks,
so better trust fdisk numbers instead.
mkdir /ext/images ; cd /ext/images
dd if=/dev/ad4 skip=0         count=2048    of=skip=0_________count=2048
dd if=/dev/ad4 skip=2048      count=407552  of=skip=2048______count=407552
    Do not do:
        dd if=/dev/ad4 skip=409600    count=457328640   of=skip=409600
    as it would be 234G, bigger than /ext, & we have already done
        "ntfsresize -n -s 65G -v /dev/ad4s2"
    man ntfsresize: G=10^9
    man dd:     1048576 (1M)
            default bs=512
    Note from above df -b (based on mount from ntfs3g I think)
    that the actual size of a file system is a bit bigger than the free space
    it delivers, so err on the side of caution & use 67 G
        dc 67 1024 1024 2 * * * p
dd if=/dev/ad4 skip=409600    count=140509184 of=skip=409600____count=140509184
    71940702208 bytes in 2947.108953 secs (24,410,601 bytes/sec)
dd if=/dev/ad4 skip=457738240 count=30445568  of=skip=457738240_count=30445568
    15588130816 bytes in 2455.149309 secs (6349158 bytes/sec)
dd if=/dev/ad4 skip=488183808 count=211312  of=skip=488183808_count=211312
    108191744 bytes transferred in 17.698979 secs (6112881 bytes/sec)
dd if=/dev/ad4 skip=488395120 count=1680    of=skip=488395120_count=1680
    860160 bytes transferred in 0.279383 secs (3078785 bytes/sec)
dd if=/dev/ad4 skip=488396800                   of=skip=488396800
    Worked ! Why ?
# Copied F3 data into F2
    ntfs-3g       /dev/ad4s1 /lap/2
    ntfs-3g -o ro /dev/ad4s2 /lap/3
    mkdir /lap/2/hp3jhs
    cd /lap/2/hp3jhs
    ( cd /lap/3 ; tar cf - . ) | tar xf -
    #   Ran with no error. du -s reports 12.6 G, as it should,
    #   & df now show /lap/2 as 50.7G, was 43.9 before.
    #   strange. only increased  6.7G, presumably because of
ntfs-3g Bugs
mount -t ufs /dev/da1a /ext ; cd /ext
mkdir -p /ext/images
cd    /ext/images
# Grab images, don't just use tar, as tar would just capture trees,
# but might miss extra ntfs attributes & boot blocks etc:
dd if=/dev/ad4 skip=0         count=2048      of=skip=0_________count=2048
dd if=/dev/ad4 skip=2048      count=407552    of=skip=2048______count=407552
dd if=/dev/ad4 skip=409600    count=140509184 of=skip=409600____count=140509184
dd if=/dev/ad4 skip=457738240 count=30445568  of=skip=457738240_count=30445568
dd if=/dev/ad4 skip=488183808 count=211312    of=skip=488183808_count=211312
dd if=/dev/ad4 skip=488395120 count=1680      of=skip=488395120_count=1680
dd if=/dev/ad4 skip=488396800                 of=skip=488396800
ln -s skip=0_________count=2048         s0    ; echo Unallocated by Fdisk, Boot
ln -s skip=2048______count=407552       s1    ; echo F1 MS Start
ln -s skip=409600____count=140509184    s2    ; echo F2 MS Main
ln -s skip=457738240_count=30445568     s3    ; echo F3 HP
ln -s skip=488183808_count=211312       s4    ; echo F4 MS backup ?
ln -s skip=488395120_count=1680         s5    ; echo Unallocated by Fdisk
ln -s skip=488396800                    s6    ; echo Beyond Fdisk
Reinstalling MS on larger disk:
fdisk /dev/ad4
  parameters extracted from in-core disklabel are:
  cylinders=1938021 heads=16 sectors/track=63 (1008 blks/cyl)
  Figures below won't work with BIOS for partitions not in cyl 1
  parameters to be used for BIOS calculations are:
  cylinders=1938021 heads=16 sectors/track=63 (1008 blks/cyl)
  Media sector size is 512
  Warning: BIOS sector numbering starts with sector 1
  Information from DOS bootblock is:
  The data for partition 1 is:
  sysid 6 (0x06),(Primary DOS, 16 bit FAT (>= 32MB))
      start 63, size 614399121 (299999 Meg), flag 0
          beg: cyl 0/ head 1/ sector 1;
          end: cyl 1023/ head 15/ sector 63
  The data for partition 2 is:
  sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
      start 614399184, size 1339125984 (653870 Meg), flag 0
          beg: cyl 1023/ head 255/ sector 63;
          end: cyl 1023/ head 15/ sector 63
  The data for partition 3 is:
  <UNUSED>
  The data for partition 4 is:
  sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
      start 614399184, size 1339125984 (653870 Meg), flag 80 (active)
          beg: cyl 243/ head 0/ sector 1;
          end: cyl 612/ head 15/ sector 63
sysctl kern.geom.debugflags=16
fdisk -u /dev/ad4
-----
fdisk -u /dev/ad4
  ******* Working on device /dev/ad4 *******
  parameters extracted from in-core disklabel are:
  cylinders=1938021 heads=16 sectors/track=63 (1008 blks/cyl)
  Figures below won't work with BIOS for partitions not in cyl 1
  parameters to be used for BIOS calculations are:
  cylinders=1938021 heads=16 sectors/track=63 (1008 blks/cyl)
  Do you want to change our idea of what BIOS thinks ? [n]
  Media sector size is 512
  Warning: BIOS sector numbering starts with sector 1
  Information from DOS bootblock is:
  The data for partition 1 is:
  sysid 6 (0x06),(Primary DOS, 16 bit FAT (>= 32MB))
      start 63, size 614399121 (299999 Meg), flag 0
          beg: cyl 0/ head 1/ sector 1;
          end: cyl 1023/ head 15/ sector 63
  Do you want to change it? [n] y
  Supply a decimal value for "sysid (165=FreeBSD)" [6] 7
  Supply a decimal value for "start" [63] 2048
  Supply a decimal value for "size" [614399121] 407552
  fdisk: WARNING: partition does not start on a head boundary
  fdisk: WARNING: partition does not end on a cylinder boundary
  fdisk: WARNING: this may confuse the BIOS or some operating systems
  Correct this automatically? [n]
  Explicitly specify beg/end address ? [n]
  sysid 7 (0x07),(NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX)
      start 2048, size 407552 (199 Meg), flag 0
          beg: cyl 2/ head 0/ sector 33;
          end: cyl 406/ head 5/ sector 37
  Are we happy with this entry? [n] y
  The data for partition 2 is:
  sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
      start 614399184, size 1339125984 (653870 Meg), flag 0
          beg: cyl 1023/ head 255/ sector 63;
          end: cyl 1023/ head 15/ sector 63
  Do you want to change it? [n] y
  Supply a decimal value for "sysid (165=FreeBSD)" [165] 7
  Supply a decimal value for "start" [614399184] 409600
  Supply a decimal value for "size" [1339125984] 457328640
  fdisk: WARNING: partition does not start on a head boundary
  fdisk: WARNING: partition does not end on a cylinder boundary
  fdisk: WARNING: this may confuse the BIOS or some operating systems
  Correct this automatically? [n]
  Explicitly specify beg/end address ? [n]
  sysid 7 (0x07),(NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX)
      start 409600, size 457328640 (223305 Meg), flag 0
          beg: cyl 406/ head 5/ sector 38;
          end: cyl 473/ head 6/ sector 22
  Are we happy with this entry? [n] y
  The data for partition 3 is:
  <UNUSED>
  Do you want to change it? [n] y
  Supply a decimal value for "sysid (165=FreeBSD)" [0] 7
  Supply a decimal value for "start" [0] 457738240
  Supply a decimal value for "size" [0] 30445568
  fdisk: WARNING: partition does not start on a head boundary
  fdisk: WARNING: partition does not end on a cylinder boundary
  fdisk: WARNING: this may confuse the BIOS or some operating systems
  Correct this automatically? [n]
  Explicitly specify beg/end address ? [n]
  sysid 7 (0x07),(NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX)
      start 457738240, size 30445568 (14866 Meg), flag 0
          beg: cyl 473/ head 6/ sector 23;
          end: cyl 981/ head 5/ sector 21
  Are we happy with this entry? [n] y
  The data for partition 4 is:
  sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
      start 614399184, size 1339125984 (653870 Meg), flag 80 (active)
          beg: cyl 243/ head 0/ sector 1;
          end: cyl 612/ head 15/ sector 63
  Do you want to change it? [n]
  Partition 4 is marked active
  Do you want to change the active partition? [n]
  We haven't changed the partition table yet.  This is your last chance.
  parameters extracted from in-core disklabel are:
  cylinders=1938021 heads=16 sectors/track=63 (1008 blks/cyl)
  Figures below won't work with BIOS for partitions not in cyl 1
  parameters to be used for BIOS calculations are:
  cylinders=1938021 heads=16 sectors/track=63 (1008 blks/cyl)
  Information from DOS bootblock is:
  1: sysid 7 (0x07),(NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX)
      start 2048, size 407552 (199 Meg), flag 0
          beg: cyl 2/ head 0/ sector 33;
          end: cyl 406/ head 5/ sector 37
  2: sysid 7 (0x07),(NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX)
      start 409600, size 457328640 (223305 Meg), flag 0
          beg: cyl 406/ head 5/ sector 38;
          end: cyl 473/ head 6/ sector 22
  3: sysid 7 (0x07),(NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX)
      start 457738240, size 30445568 (14866 Meg), flag 0
          beg: cyl 473/ head 6/ sector 23;
          end: cyl 981/ head 5/ sector 21
  4: sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
      start 614399184, size 1339125984 (653870 Meg), flag 80 (active)
          beg: cyl 243/ head 0/ sector 1;
          end: cyl 612/ head 15/ sector 63
  Should we write new partition table? [n] y
  fdisk: Class not found
fdisk /dev/ad4
  ******* Working on device /dev/ad4 *******
  parameters extracted from in-core disklabel are:
  cylinders=1938021 heads=16 sectors/track=63 (1008 blks/cyl)
  Figures below won't work with BIOS for partitions not in cyl 1
  parameters to be used for BIOS calculations are:
  cylinders=1938021 heads=16 sectors/track=63 (1008 blks/cyl)
  Media sector size is 512
  Warning: BIOS sector numbering starts with sector 1
  Information from DOS bootblock is:
  The data for partition 1 is:
  sysid 7 (0x07),(NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX)
      start 2048, size 407552 (199 Meg), flag 0
          beg: cyl 2/ head 0/ sector 33;
          end: cyl 406/ head 5/ sector 37
  The data for partition 2 is:
  sysid 7 (0x07),(NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX)
      start 409600, size 457328640 (223305 Meg), flag 0
          beg: cyl 406/ head 5/ sector 38;
          end: cyl 473/ head 6/ sector 22
  The data for partition 3 is:
  sysid 7 (0x07),(NTFS, OS/2 HPFS, QNX-2 (16 bit) or Advanced UNIX)
      start 457738240, size 30445568 (14866 Meg), flag 0
          beg: cyl 473/ head 6/ sector 23;
          end: cyl 981/ head 5/ sector 21
  The data for partition 4 is:
  sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
      start 614399184, size 1339125984 (653870 Meg), flag 80 (active)
          beg: cyl 243/ head 0/ sector 1;
          end: cyl 612/ head 15/ sector 63
Unused sectors: 457738240+30445568=488183808 to 614399184-1=614399183
reboot to test. OK
sysctl kern.geom.debugflags=16
fdisk -a /dev/ad4
reboot to test.
    boots to BSD though shows partition 1 marked active
sysctl kern.geom.debugflags=16
reboot to test.
doesn't even offer F1-F4 just says Missing operating system,
reboot with stick
fdisk -a /dev/ad4 # set to 4, boots OK
Now re-install MS
Could use:
  dd if=skip=2048______count=407552 seek=2048 count=407552 of=/dev/ad4 ;
But used:
  dd if=skip=2048______count=407552    of=/dev/ad4s1
    268890 bytes/sec    at powerd -a minimum
  dd if=skip=409600____count=140509184 of=/dev/ad4s2
                at powerd -a adaptive
Somewhat inefficient, I should have used a bs=1024k
(which I did not as wasn't sure if end would get chopped,
i did a test after on another host, & seen end does not get chopped)
However
     maybe no bad thing to be inefficient,
        slower disk access = less heat = less risk of crashing.
    + I'm getting 10 Mbyte from file on FS, to raw partition on
    same disk, so a lot of seeks, not such bad performance.
    host fire only does 40 or so when just doing write with
    testblock ( no reading as well, so no seeks)
iostat -w 1 # 10 MB/s
so 70 Gig / 10 Mbyte/s = 7000 Sec = 117 mins. = 2 hours wait.
    140509184+0 records in 140509184+0 records out
    71940702208 bytes transferred in 13695.792634 secs (5252759 bytes/sec)
dd if=skip=457738240_count=30445568  of=/dev/ad4s3 bs=1024K
    14866+0 records in 14866+0 records out
    15588130816 bytes transferred in 840.984104 secs (18535583 bytes/sec)
sysctl kern.geom.debugflags=16
fdisk -a /dev/ad4
reboot to test.
Windows Boot Manager
Windows failed to start
Insert your windows installation disk. & restart
...
Boot failed because a required device is inaccessible
Cant get PC to recognise F keys for F4 + BSD
Connected external disk & reboot
 
cd mnt ; mkdir 1 2 3 4
mdconfig -a -t vnode -f s1
mdconfig -a -t vnode -f s2
mdconfig -a -t vnode -f s3
mdconfig -a -t vnode -f s4
Avoid ntfs-3g because of ntfs-3g Bug use
mount -t ntfs (which only supports "read only" not write.
mount -r -t ntfs    /dev/md0 /mnt/1
mount -r -t ntfs    /dev/md1 /mnt/2
mount -r -t ntfs    /dev/md2 /mnt/3
mount -r -t msdosfs /dev/md3 /mnt/4
umount  /lap/4
umount  /lap/3
umount  /lap/2
umount  /lap/1
mdconfig -d -u 3
mdconfig -d -u 2
mdconfig -d -u 1
mdconfig -d -u 0
 
        
        
          /usr/local/bin/ntfs-3g As built from FreeBSD-8.2-RELEASE
          /usr/ports/sysutils/fusefs-ntfs/Makefile 
           Has Multiple Bugs: 
           
            PORTVERSION= 2010.10.2BUILD_DEPENDS=
            fusefs-libs>=2.7.2:${PORTSDIR}/sysutils/fusefs-libs
 
          Name of Files & directories starting with a '$' are
          not seen. Certainly they failed to be delivered when file
          systems mounted with ntfs-3g & copied using 
           
            (cd /lap/3 ; tar cf - . ) | ( cd /lap/2/hp3hgs ; tar xf
            - )
           
          List of what failed to copy: 
           
$AttrDef
$BadClus
$Bitmap
$Boot
$Extend/$ObjId
$Extend/$Quota
$Extend/$Reparse
$Extend/$RmMetadata/$Repair
$Extend/$RmMetadata/$TxfLog/$Tops
$Extend/$RmMetadata/$TxfLog/$TxfLog.blf
$Extend/$RmMetadata/$TxfLog/$TxfLogContainer00000000000000000001
$Extend/$RmMetadata/$TxfLog/$TxfLogContainer00000000000000000002
$LogFile
$MFTMirr
$Secure
$UpCase
$Volume
 
          As viewed by a normal mount -t ntfs ; cd /lap/img1/2 ;
          /bin/ls -l 
           
-rwxr-xr-x  1 root  bin        2560 Jan  1  1601 $AttrDef
-rwxr-xr-x  1 root  bin           0 Apr  8  2011 $BadClus
-rwxr-xr-x  1 root  bin     1983648 Jan  1  1601 $Bitmap
-rwxr-xr-x  1 root  bin        8192 Apr  8  2011 $Boot
drwxr-xr-x  1 root  bin           0 Apr  8  2011 $Extend
-rwxr-xr-x  1 root  bin    67108864 Apr  8  2011 $LogFile
-rwxr-xr-x  1 root  bin        4096 Apr  8  2011 $MFTMirr
drwxr-xr-x  1 root  bin           0 Apr  9  2011 $Recycle.Bin
-rwxr-xr-x  1 root  bin           0 Apr  8  2011 $Secure
-rwxr-xr-x  1 root  bin      131072 Apr  8  2011 $UpCase
-rwxr-xr-x  1 root  bin           0 Apr  8  2011 $Volume
 
          cd '/lap/img1/2/$Extend' ; /bin/ls -l 
           
-rwxr-xr-x  1 root  bin  0 Apr  8  2011 $ObjId
-rwxr-xr-x  1 root  bin  0 Apr  8  2011 $Quota
-rwxr-xr-x  1 root  bin  0 Apr  8  2011 $Reparse
drwxr-xr-x  1 root  bin  0 Apr  8  2011 $RmMetadata
-rwxr-xr-x  1 root  bin  0 Apr  8  2011 $UsnJrnl
 
          Another Bug is not even du runs on the trees ! I saw this
          after copying stuff from F3 to add to F2, So I forced a
          clean: 
           
umount /lap/1 /lap/2 /lap/3 /lap/4
/usr/local/bin
/usr/local/bin/ntfsfix /dev/ad4s1
/usr/local/bin/ntfsfix /dev/ad4s2
/usr/local/bin/ntfsfix /dev/ad4s3
sync
halt -p
Boot MS, watch chkdsk run
 
          Boot BSD - again du & tar fails on Unable to continue
          to traverse directory tree. Those fuse mounts also fail
          if the external disk is moved to another BSD support PC. 
           Another problem seen is 
            fuse: failed to exec mount program: No such file or
            directory This is solved by installing those extra
            PORTS listed above on the stick.
          
          ftp refuses to "put /dev/ad4s1" - it should not error,
          should just warn.JJLATER: redo, catch error message, & search the
          source
 /usr/src/usr.bin/ftp/../../contrib/lukemftp
 Loosening this ftp feature check would help with moving
          /dev/ad4s[134] but not with /dev/ad4s2, as fdisk still
          guides /dev/ad4s2 to consider itself as > 200G, (too
          big to receive on support host) although within S2 we
          have run ntfsresize to reduce it to 60G or so.
 
          Various random bad block errors on 2 disks, using laptops
          drives in external chassis-es with power doubler cables,
          even straight on to sockets on back of tower host name
          blak (newish, power should be OK, electrolytics shouldn't
          be old) sockets direct on main board, (not the sockets at
          front of PC that might have extra wire resistance). 
           JJLATER: Voltage Test Pending. Some USB hubs &
          transformers suspect. Some voltages too low, one too
          high. 
           JJLATER : Test hubs & transformers later, measuring
          voltage on load, & using testblock  Move external disk off of the notebook
          & off the support tower, & on to hubs to reduce
          power. Moved fan (0.62A) off the disk hub on to a spare
          hub)
         NotesBig file: 12G F3/preload/base.wim |